Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default 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....?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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....?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
subtracting date/time Nathan Excel Worksheet Functions 8 January 29th 09 03:29 AM
Subtracting Date/Time Sapphyre Excel Discussion (Misc queries) 4 August 21st 07 01:42 AM
Subtracting time in date format Collcat Excel Worksheet Functions 1 November 10th 04 09:40 PM
Subtracting time in date format Collcat Excel Worksheet Functions 1 November 10th 04 08:42 PM
Subtracting time in date format Collcat Excel Worksheet Functions 1 November 10th 04 04:45 PM


All times are GMT +1. The time now is 04:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"