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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to calculator hours difference combine with the date and time

Status
Not open for further replies.

tongw

Programmer
Oct 20, 2016
9
US
Hello,

I am trying to calculator hours differences that combine with date and time

e.g:

date1(dd/mmm/yyyy) time1(hh:mm:ss)
date2(dd/mmm/yyyy) time2(hh:mm:ss)

hours difference= (date2 + time2) - (date1+time1) .....????


Thanks
 
You will need to use the SecondsAfter method which will give you the seconds difference between the dates. You will also need the DaysAfter method to get the number of days between the two dates. After that it is just a matter of converting days and seconds to hours.

Matt

"Nature forges everything on the anvil of time"
 
The days could be calculated like this but how to get the expression:

if time2>time1, (daysafter( date1, date2 )) + abs(secondsafter(time1, time2)/86400)

if time2<time1, ((daysafter( date1, date2 )) + abs(secondsafter(time1, time2)/86400))-1

I tried but got the error messages...

Thanks!





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top