Weeknumber is off

H

Harmannus

Hallo,

I use the below code to generate a weeknumber

Week: Format(DatePart("ww";[Mydate]);"00")

If Mydate is 10 january Access says its week 3. This is probebly due to the
fact that last yeas was a year with 53 weeks. The first of january started
in week 53...

Any suggestions on how to correct this?

Thanx for any tips!

Regards,
Harmannus
 
T

tina

it's due to the default settings of the DatePart() function: the default
value for the third argument FirstDayOfWeek is Sunday, and the default value
for the fourth argument FirstWeekOfYear is Jan1. this means that the week in
which Jan 1 falls is week one, even when Jan 1 falls on the last day of the
week, as it did this year.

you can change the FirstDayOfWeek setting to Saturday, as

DatePart("ww", [Mydate], 7)

or, you can change the FirstDayOfYear setting to FirstFullWeek, as

DatePart("ww", [Mydate], , 3)

suggest you read up on the DatePart Function topic in Help, for an in-depth
explanation.

hth
 

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