DateDiff("w") -- problem

  • Thread starter Thread starter zSplash
  • Start date Start date
Z

zSplash

I am trying to count weekdays, using the "w" argument unsuccessfully. I get
the same value for "w" (weekday) as I do for "ww" (week). What am I doing
wrong?
Code:
estDays=DateDiff("w", ufm1.Calendar1, ufm1.Calendar2)

TIA
 
I'm not aware of the "w" or "ww" arguments. Where did you find them
documented?
 
Hi Niek!

zSplash is talking about the vba DATEDIFF not the mysterious Workbook
function DATEDIF

Datediff is documented in Help for all versions since at least Excel
97.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Hi zSplash!

I think that you are misunderstanding what DATEDIFF means by "w" and
"ww" arguments.

Extract from Help:

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.

Both are counting weeks which is why in your case you are getting the
same answer.

To count weekdays use the Analysis ToolPak NETWORKDAYS function.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Absolutely right, Norman. I always assumed they were just the VBA and the SS
version of one and the same thing, but that turns out to be completely
wrong.

Thanks!

--

Kind Regards,

Niek Otten

Microsoft MVP - Excel
 
Thanks, Norman, for the help. I guess I just didn't read the expanded help,
and assumed. Sorry.

So, how do I access (or install, if necessary) the "Analysis Toolpack"
functions? This is new to me. (I don't see it in my References...)

st.
 
Hi zSplash!

You and me both! I was misled by the intro description and didn't look
closer until I got the same results that you did.

Last resort? Read The Fine Manual.

See you around the newsgroups.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
is it available under tools=>Addins? If so, check both Analysis Tookpak
and Analysis Toolpak - VBA. The later contains the VBA callable versions of
the functions.

If not go to the control panel and do add/remove software and start office
install.
 

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

problem with date formula 5
datediff 5
Userform 1
iif expected end of statement 2
Data mismatch 4
DateDiff excluding weekends - one case not working 1
Selecting proper week 1
DatePart Function in VBA 3

Back
Top