PC Review


Reply
Thread Tools Rate Thread

DateDiff Returning Zero

 
 
Paul
Guest
Posts: n/a
 
      15th Jan 2007
Access 2007 Trial. I have to fields in the form footer, [Min Date] (=
Min([Date Worked]) and [Max Date] (=Max([Date Worked]) both work fine. When
I try to use DateDiff on them I zero returned. I have DateDiff("w", [Min
Date], [Max Date]) as I only want to count weekdays. Test data is populated
with data running from 01/11/2007 - 01/15/2007 and I'm expecting it to
return 3. Any ideas?

Thanks

Paul


 
Reply With Quote
 
 
 
 
John Vinson
Guest
Posts: n/a
 
      15th Jan 2007
On Mon, 15 Jan 2007 11:10:06 -0500, "Paul"
<(E-Mail Removed)> wrote:

>Access 2007 Trial. I have to fields in the form footer, [Min Date] (=
>Min([Date Worked]) and [Max Date] (=Max([Date Worked]) both work fine. When
>I try to use DateDiff on them I zero returned. I have DateDiff("w", [Min
>Date], [Max Date]) as I only want to count weekdays. Test data is populated
>with data running from 01/11/2007 - 01/15/2007 and I'm expecting it to
>return 3. Any ideas?


DateDiff knows NOTHING about workdays, and that's not what the "w"
does; in practice, "w" and "d" both return the integer number of days,
and I've never understood why the "w" is provided at all. You'll need
to use some VBA, and probably a table of holidays as well; you don't
really want to count *weekdays* but *workdays*, so if Monday is being
observed as a holiday (pausing to remember Rev. King...) you would
want to take it out of the count as well. There's sample code at

http://www.mvps.org/access/datetime/date0012.htm

John W. Vinson[MVP]


 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      15th Jan 2007
Great, thank you both. I'll give them both a try.

Paul


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateDiff returning incorrect years mewins Microsoft Access Queries 11 31st Aug 2009 08:22 PM
Returning to previous record (if exists) instead of returning to the first record in a form after requery Amir Microsoft Access Form Coding 6 1st Mar 2006 04:46 PM
DateDiff function returning incorrect results in asp.net 2.0 vb =?Utf-8?B?cmVuZXk=?= Microsoft VB .NET 7 13th Feb 2006 06:39 AM
DateDiff Returning Negative Numbers =?Utf-8?B?dm1m?= Microsoft Access Queries 2 14th Dec 2005 03:52 PM
Re: How can I find DATEDIFF returning Year, Months & Days Dave Peterson Microsoft Excel Misc 0 3rd Sep 2004 01:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:50 AM.