Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Calculate Number of HOURS Between Two Date/Time Fields


Message #1 by "Jamie Starkey" <jastarkey@i...> on Fri, 28 Feb 2003 16:17:30
All - 
I am needing to calculate the difference in hours between two date/time 
fields (date format set to General for lack of a better idea). It would 
seem relatively easy using the DateDiff function - however I need to 
exclude weekend and holiday hours. Can someone advise on how to do this? 
Can either this function or the Network days function be modified to 
accommodate this? 
And a further question if possible: since these two fields are required - 
what is the syntax of the input mask for both a required date and a 
required time? Nothing I've tried has been successful.

Thanks!
Jamie
Message #2 by "Gregory Serrano" <SerranoG@m...> on Fri, 28 Feb 2003 16:46:06
Jamie,

<< I am needing to calculate the difference in hours between two date/time 
fields (date format set to General for lack of a better idea). It would 
seem relatively easy using the DateDiff function - however I need to 
exclude weekend and holiday hours. >>

The syntax of the DateDiff function is this:

   DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

To just count weekdays, make sure the interval is set to "w" instead 
of "d".  To get hours, use "h".

To exclude holidays, you'll have to manually list holidays and their dates 
on a table; and then program your code to see if any holidays fall between 
your start and end date, and then subtract them.

<< what is the syntax of the input mask for both a required date and a 
required time? >>

The input mask is whatever you desire and set.  DateDiff will work with 
any input mask you give it.

Greg

  Return to Index