Return the week # for a given date?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does anyone know of a function or set of functions which can retrieve the
week number for a given date?

For example: Given date 1/16/2006 would return 3 for the 3rd week in the year.

Thanks,

Sarah
 
Sarah

I don't recall if there's a specific function (there easily could be, I just
don't recall), but you could use a query and the Format() function to
display a date as a week number.

Check Access HELP for Format() and for date-related functions.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Does anyone know of a function or set of functions which can retrieve the
week number for a given date?

For example: Given date 1/16/2006 would return 3 for the 3rd week in the year.

Thanks,

Sarah

DatePart("ww", [datefield])

Open the VBA editor and look at the Help for DatePart. There are
several options to determine what is the first week of the year (If
January 1 were a Saturday, is January 3 in the first week or the
second?)

John W. Vinson[MVP]
 
Thanks guys!

John Vinson said:
Does anyone know of a function or set of functions which can retrieve the
week number for a given date?

For example: Given date 1/16/2006 would return 3 for the 3rd week in the year.

Thanks,

Sarah

DatePart("ww", [datefield])

Open the VBA editor and look at the Help for DatePart. There are
several options to determine what is the first week of the year (If
January 1 were a Saturday, is January 3 in the first week or the
second?)

John W. Vinson[MVP]
 
Sarah said:
Does anyone know of a function or set of functions which can retrieve the
week number for a given date?

For example: Given date 1/16/2006 would return 3 for the 3rd week in the
year.

Run in the immediate window:

? Format(#1/16/2006#,"w")
2

Note that it gives 2 rather than 3, so you need to place the cursor on
"Format" and press F1 for help, which will give you information about two
other arguments, firstdayofweek and firstweekofyear, which will affect the
result.

Larry Linson
Microsoft Access MVP
 
John Vinson said:
Does anyone know of a function or set of functions which can retrieve the
week number for a given date?

For example: Given date 1/16/2006 would return 3 for the 3rd week in the year.

Thanks,

Sarah

DatePart("ww", [datefield])

Open the VBA editor and look at the Help for DatePart. There are
several options to determine what is the first week of the year (If
January 1 were a Saturday, is January 3 in the first week or the
second?)

John W. Vinson[MVP]
 
does someone know how to convert my weekly date format into a short date?

My data reads YYYYWW - (i.e. 200801 is the first week in 2008)

I need to use 01/31/08 in form selection for the corresponding week in the
table -

Thanks,
 
WeekNum: DateDiff("ww",DateSerial(Year(?),1,1),?)+1

The ? has to contain the reference to the date ie. [kjhefv]![kdkasf]
 
Almost Lee...

but my column/field has the year concatenated with the week number...

I am trying to do the reverse...get a conventional date fomat from data that
looks like 200901 (first week in 2009)
 
Back
Top