java.util.Calendar.getInstance().get(java.util.Calendar.WEEK_OF_YEAR);
my $weekNumber = POSIX::strftime("%V", gmtime time);
Replace time with other UNIX timestamps for other week numbers.
$weekNumber = date("W");
or date("W", epoch)
for other week numbers. Remember to use capital 'W' not 'w'.
SELECT WEEKOFYEAR(NOW())
Replace now() with other dates eg. SELECT WEEKOFYEAR('2008-02-20');
(You can also use the WEEK function with mode=3 select week(now(),3)
)
SELECT DATEPART( wk, GETDATE() )
[NSString stringWithFormat:@"Week %d", [calendar ordinalityOfUnit:NSWeekCalendarUnit inUnit:NSYearCalendarUnit forDate:date]];
import time week_number_as_string = time.strftime("%W") week_number = int(week_number_as_string)
week_number = Time.now.strftime("%U")Replace Time.now with Time.local(year,month,day) for other dates.
=WEEKNUM(A1)-1Week numbers can vary based on your locality settings (not ISO-8601!). See discussion below.
date +%W