Count Weeks

S

scott

I've got 2 variables named BeginYearDate and EndYearDate that I'd like to
find the total number of weeks or 7 day periods between the 2 dates.

For example: 12/28/2003 and 12/27/2004 would be 52 weeks

Is there a way to use date functions to calculate the weeks and prevent me
from looping through and counting every 7 day interval between the 2 dates?

Scott
 
Y

Yuan Shao

Hi Scott,

Thanks for your post. As I understand, you want to count number of weeks
between two specified date. If I have miunderstood, please feel free to let
me know.

Based on my research, the function DateDiff() should meet your requirements.

For example:

DateDiff("w", #12/28/2003#, #12/27/2004#)

the returned value is 52.

Please feel free to post in the group if this solves your problem or if you
would like further assistance.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Y

Yuan Shao

The cust wants to count the number of weeks between two specified date. The
DateDiff() function should meet his requirements.

/////////////////////////

email-yes. Waiting on cust.
 
J

Jonathan Parminter

-----Original Message-----
I've got 2 variables named BeginYearDate and EndYearDate that I'd like to
find the total number of weeks or 7 day periods between the 2 dates.

For example: 12/28/2003 and 12/27/2004 would be 52 weeks

Is there a way to use date functions to calculate the weeks and prevent me
from looping through and counting every 7 day interval between the 2 dates?

Scott
Hi Scott, use online help to lookup the function DateDiff.
Use the "ww" switch.

for example

intWeeks = DateDiff("ww",BeginYearDate, EndYearDate)

If required convert dates into m/d/yy format before the
above calculation (really annoying for anyone outside usa!)

Luck
Jonathan
 
J

John Spencer (MVP)

The DateDiff function may be of use, but if you just want the number of complete
seven day periods, you can use a little integer math.

EndYearDate-BeginYearDate \ 7

And note operator is \ not /

DateDiff will return a number of weeks; however, it returns the number of times
the week changes. So 12/26/2003 to 12/29/03 (three days, will in most cases
return ONE week since you have crossed the boundary day between the two
different weeks.
 

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