#1   Report Post  
rob
 
Posts: n/a
Default date & time

Is there any formula to calculate dates and times. I would like to input a
start date then input an end date and have a formula that will calculate how
many days/weeks/months have passed (this would have to take into account leap
year). I would also like to do this for time. Input start time and end time
and calculate how many hours/minutes/seconds have passed. Finally input a
start time such as 1:00 pm add 45 minutes and have the answer be 1:45 pm.

Any help would be appreciated.
  #2   Report Post  
Myrna Larson
 
Posts: n/a
Default

Dates are stored in Excel as the number of elapsed days since "Day 0", which
was arbitrarily chosen to be Dec 31, 1899. So the number 1 represents Jan 1,
1900, and the number 38614 represents Sep 19, 2005.

There is an undocumented function, DATEDIF, that will calculate elapsed time.
Assuming the earlier date in A1 and the later date in B1:

=DATEDIF(A1,B1,"y") for years
=DATEDIF(A1,B1, "ym") for months in the last partial year
=DATEDIF(A1,B1, "md" for days in the last partial month

For subtracting times, if the difference is less than 24 hours, the earlier
time is in B1 and the later time in A1,

=HOUR(B1-A1)
=MINUTE(B1-A1)
=SECOND(B1-A1)

If the clock crosses midnight between the start time and end time, then in
each of the above formulas, replace
B1-A1
with
B1-A1+B1<A1

If the difference could be 24 hours, then the values in A1 and B1 must
include both the date and the time, and the formula for hours would be

=(INT(B1)-INT(A1))*24+HOUR(B1-A1)

On Mon, 19 Sep 2005 14:42:01 -0700, rob wrote:

Is there any formula to calculate dates and times. I would like to input a
start date then input an end date and have a formula that will calculate how
many days/weeks/months have passed (this would have to take into account leap
year). I would also like to do this for time. Input start time and end time
and calculate how many hours/minutes/seconds have passed. Finally input a
start time such as 1:00 pm add 45 minutes and have the answer be 1:45 pm.

Any help would be appreciated.

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
How do I create a schedule from a list of dates ? Gavin Morris Charts and Charting in Excel 2 October 28th 10 04:08 PM
Extracting Time from a cell that has both the date and the time Hani Muhtadi Excel Discussion (Misc queries) 3 September 9th 05 10:59 AM
How do I calculate if a date is in a certain time frame? Pe66les Excel Worksheet Functions 19 August 27th 05 11:07 PM
how do I format cells to change date and time to just date bondam Excel Discussion (Misc queries) 3 July 3rd 05 01:10 PM
Help - Information with time and date PM Excel Discussion (Misc queries) 4 January 6th 05 08:25 AM


All times are GMT +1. The time now is 02:26 AM.

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

About Us

"It's about Microsoft Excel"