Return the week # for a given date?

S

Sarah

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
 
J

Jeff Boyce

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
 
J

John Vinson

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]
 
S

Sarah

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]
 
L

Larry Linson

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
 
K

Ken

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]
 
K

Ken

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,
 
L

Lee

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

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

Ken

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top