VBA DateDiff interval argument for "w" isn't working

sefMI

Board Regular
Joined
Apr 24, 2006
Messages
127
Hi,
According to the VBA documentation the arguement of "w" should return the number of weekday (i assume m-f) between two dates when used in the datediff() function. When I do this it returns a -2 where my dates are 6/15/12 and 5/29/12. What gives?

Scott
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
If you look at vb Help (see Remarks), the "w" appears to count the number of weeks !!!
 
Upvote 0
Odd b/c the documentation i get from the editor is that "ww" counts weeks and "w" counts week days. Not the end of the world but would have been nice.
 
Upvote 0
Odd b/c the documentation i get from the editor is that "ww" counts weeks and "w" counts week days. Not the end of the world but would have been nice.
From the Remarks section of the VB help file for DateDiff (see red highlighted text)...

"To calculate the number of days between date1 and date2, you can use either Day of year ("y") or Day ("d"). When interval is Weekday ("w"), DateDiff returns the number of weeks between the two dates. If date1 falls on a Monday, DateDiff counts the number of Mondays until date2. It counts date2 but not date1. If interval is Week ("ww"), however, the DateDiff function returns the number of calendar weeks between the two dates. It counts the number of Sundays between date1 and date2. DateDiff counts date2 if it falls on a Sunday; but it doesn't count date1, even if it does fall on a Sunday."
 
Upvote 0

Forum statistics

Threads
1,203,252
Messages
6,054,385
Members
444,721
Latest member
BAFRA77

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top