ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   add/subtracting date:time in Excel 2000 (https://www.excelbanter.com/excel-programming/335119-add-subtracting-date-time-excel-2000-a.html)

Gordon[_2_]

add/subtracting date:time in Excel 2000
 
Office 2000/Excel. Need to add and subtract date/time values Need to
return answers like Date 1 is 2 days 6 hours and 4 minutes ahead of date
2..... or date 1 is 3 days, 12 hours, 4 minutes BEHIND date 2. Can this be
done....?



Tom Ogilvy

add/subtracting date:time in Excel 2000
 
Do you mean in VBA (this is the programming group) or using worksheet
formulas. In VBA, (demo'd from the immediate window:)

? d1, d2
1/15/05 1:15:00 PM 1/17/05 5:30:00 PM

? datediff("n",d1,d2)
3135
? datediff("n",d1,d2)/(24#*60#)
2.17708333333333

So Int( 2.17708333333333 ) gives you 2 days.
subtract that from 2.17708333333333 and you get .17708333333333
multiply that times 24 and you get the remainder in hours.
4.24999999999992

follow a similar procedure to reduce 4.24999999999992 to get 4 hours and

..24999999999992 x 60 = 14.9999999999952 or round it for 15 minutes.


2 days, 5 hours and 15 minutes.

--
Regards,
Tom Ogilvy





"Gordon" wrote in message
...
Office 2000/Excel. Need to add and subtract date/time values Need to
return answers like Date 1 is 2 days 6 hours and 4 minutes ahead of date
2..... or date 1 is 3 days, 12 hours, 4 minutes BEHIND date 2. Can this

be
done....?






All times are GMT +1. The time now is 01:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com