Week number from date

B

blake7

Hi all, I have the code below in a text box which is returning the week
number from text box 118 on a report, it is returning week 4 when the date in
the text box is 18th January 2010 when actually it should read week 3, can
anyone tell me what is wrong? Thanks

=DatePart("ww",[text118])
 
J

John Spencer

Use the additional parameters of DatePart to set what is to be used to
calculate when week 1 starts. For instance

DatePart("ww",#2010-01-18#,vbsunday,vbFirstFullWeek) returns 3
and
DatePart("ww",#2010-01-18#,vbsunday,vbFirstFourDays) returns 3
but
DatePart("ww",#2010-01-18#,vbsunday,vbFirstJan1) returns 4

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
J

Jerry Whittle

DatePart has some arguments such as the first day of the week and first week
of the year. Below might work for you; however, you really need to check all
the options to see what meets your business rules.

DatePart("ww",[text118],,3)
 
B

blake7

Thanks Guys, I used Jerry's solution although I had to remove one of the
comma's at the end - eg DatePart("ww",[text118],3) and it works fine.
Thanks. Tony

Jerry Whittle said:
DatePart has some arguments such as the first day of the week and first week
of the year. Below might work for you; however, you really need to check all
the options to see what meets your business rules.

DatePart("ww",[text118],,3)
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


blake7 said:
Hi all, I have the code below in a text box which is returning the week
number from text box 118 on a report, it is returning week 4 when the date in
the text box is 18th January 2010 when actually it should read week 3, can
anyone tell me what is wrong? Thanks

=DatePart("ww",[text118])
 

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

Similar Threads

Week Number 2
Get date for start of week 3
Week number 1
Week numbers 2
Creating a date from week number, day number and year value 1
Return week number 11
extracting a weeks worth of data in a query 6
Week Number 4

Top