Count Weeks

  • Thread starter Thread starter scott
  • Start date Start date
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
 
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.
 
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.
 
-----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
 
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.
 
Back
Top