Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff question 1

Status
Not open for further replies.

yoshe

Technical User
Jan 12, 2007
36
US
Hello, I think this is a simple question (I'm not an advanced user). I would like to number weeks relative to ending Friday - ie, April 26, 2008 through May 2, 2008 would be counted in the same week. The formula I tried was:

WeekNumber=DateDiff("w",StartDate,X_date,vbSaturday)

but this still puts a Friday and the next day Saturday within the same week. I want that Saturday included in the next week. What am I doing wrong?
Thanks for any help!
 




Hi,

I often use this formula to calculate the SAT, Beginning Of Week...
Code:
dBOW = Int((YourDate-2)/7)*7
Then the difference between dBOW and x_date will give you the number of days. Take the Int of that value to get the number of FULL WEEKS.


Skip,

[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue]
 
The interval argument has these settings:

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second

so it seems to me you want ww if you're counting weeks or d if you're counting days. w counts only weekdays (so Saturday wouldn't count).

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top