Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Pontoon
 
Posts: n/a
Default I need to find the yy/mm/dd AND hh:mm:ss between 2 time stamps

I need to work out the number of years, months, days AND the elapsed time
between two timestamps. I can compare dates OR Times, but not both together.

If I do a simple subtract ( A1-A2 ) with the results in A3 formatted using
the custom format
yy" Years" mm" Months" dd" Days" hh" Hours" mm" Minutes" ss" seconds"

it almost works - HOWEVER Excel seems to add a spurious month to the results.

(It seems to also do this even if I enter a zero into a cell, then format it
using the same custom format! )

I must be doing something stupid, so any help would be more than welcome.
  #2   Report Post  
Posted to microsoft.public.excel.misc
David Biddulph
 
Posts: n/a
Default I need to find the yy/mm/dd AND hh:mm:ss between 2 time stamps

"Pontoon" wrote in message
...
I need to work out the number of years, months, days AND the elapsed time
between two timestamps. I can compare dates OR Times, but not both
together.

If I do a simple subtract ( A1-A2 ) with the results in A3 formatted using
the custom format
yy" Years" mm" Months" dd" Days" hh" Hours" mm" Minutes" ss" seconds"

it almost works - HOWEVER Excel seems to add a spurious month to the
results.

(It seems to also do this even if I enter a zero into a cell, then format
it
using the same custom format! )

I must be doing something stupid, so any help would be more than welcome.


Don't forget that when you format a number as a date/time in Excel, the yy
mm dd are a date (counting from 1st January 1900).
Hence if you feed it a number 6, for example, it will be treated as 6th
January 1900 if you try to format it as a date, and if you split that format
up the dd part will be 6 and the mm part will be 01 (for January).

You may do better with the DATEDIF function:
http://www.cpearson.com/excel/datedif.htm
--
David Biddulph


  #3   Report Post  
Posted to microsoft.public.excel.misc
Pontoon
 
Posts: n/a
Default I need to find the yy/mm/dd AND hh:mm:ss between 2 time stamps

Thanks David,
But ( as I understand it ) DATEDIF will only show me one of the attributes
that I am after - number of days or years or hours between tow dates... I am
trying to get all that together.

So for example what I want is to be able to enter 01/01/2006 09:00:00 in
one cell and 18/03/2006 10:10:01 in another and for Excel to tell me that
there is 0 Years, 2 months, 16 days, 1 hour, 10 miuntes and 1 second between
them.

Currently ( with excel subtracting one cell from the other, and the results
cell custom formatted as
yy" Years" mm" Months" dd" Days" hh" Hours" mm" Minutes" ss" seconds"
Then I get the answer I expect ( but with one extra month ) !!

If I compare 2 identical time stamps the result is all zeros exept for one
month.... and the weird thing is that if I format the results cell as a
number it shows ZERO ( so I know that the calculation is correct .) It must
be a problem with the custom format???

  #4   Report Post  
Posted to microsoft.public.excel.misc
David Biddulph
 
Posts: n/a
Default I need to find the yy/mm/dd AND hh:mm:ss between 2 time stamps

"Pontoon" wrote in message
...
Thanks David,
But ( as I understand it ) DATEDIF will only show me one of the attributes
that I am after - number of days or years or hours between tow dates... I
am
trying to get all that together.

So for example what I want is to be able to enter 01/01/2006 09:00:00 in
one cell and 18/03/2006 10:10:01 in another and for Excel to tell me that
there is 0 Years, 2 months, 16 days, 1 hour, 10 miuntes and 1 second
between
them.

Currently ( with excel subtracting one cell from the other, and the
results
cell custom formatted as
yy" Years" mm" Months" dd" Days" hh" Hours" mm" Minutes" ss" seconds"
Then I get the answer I expect ( but with one extra month ) !!

If I compare 2 identical time stamps the result is all zeros exept for one
month.... and the weird thing is that if I format the results cell as a
number it shows ZERO ( so I know that the calculation is correct .) It
must
be a problem with the custom format???


My previous message told you why you've got a 1 month difference doing it
your way, & pointed you at Chip Pearson's DATEDIF site.

If you follow Chip's DATEDIF recommendations, & go on from where you were
with the time part, it should work.

=DATEDIF(A1,A2,"y")&" years "&DATEDIF(A1,A2,"ym")&" months
"&DATEDIF(A1,A2,"md")&" days "&TEXT(MOD(A2-A1,1),"hh")&" hours
"&TEXT(MOD(A2-A1,1),"hh")&" minutes "&TEXT(MOD(A2-A1,1),"hh")&" seconds"

gives
0 years 2 months 17 days 01 hours 01 minutes 01 seconds

which is, I think, the right answer. [I think your answer is a day
adrift.?]
--
David Biddulph


  #5   Report Post  
Posted to microsoft.public.excel.misc
David Biddulph
 
Posts: n/a
Default I need to find the yy/mm/dd AND hh:mm:ss between 2 time stamps

"David Biddulph" wrote in message
...
"Pontoon" wrote in message
...
Thanks David,
But ( as I understand it ) DATEDIF will only show me one of the
attributes
that I am after - number of days or years or hours between tow dates... I
am
trying to get all that together.

So for example what I want is to be able to enter 01/01/2006 09:00:00 in
one cell and 18/03/2006 10:10:01 in another and for Excel to tell me
that
there is 0 Years, 2 months, 16 days, 1 hour, 10 miuntes and 1 second
between
them.

Currently ( with excel subtracting one cell from the other, and the
results
cell custom formatted as
yy" Years" mm" Months" dd" Days" hh" Hours" mm" Minutes" ss" seconds"
Then I get the answer I expect ( but with one extra month ) !!

If I compare 2 identical time stamps the result is all zeros exept for
one
month.... and the weird thing is that if I format the results cell as a
number it shows ZERO ( so I know that the calculation is correct .) It
must
be a problem with the custom format???


My previous message told you why you've got a 1 month difference doing it
your way, & pointed you at Chip Pearson's DATEDIF site.

If you follow Chip's DATEDIF recommendations, & go on from where you were
with the time part, it should work.

=DATEDIF(A1,A2,"y")&" years "&DATEDIF(A1,A2,"ym")&" months
"&DATEDIF(A1,A2,"md")&" days "&TEXT(MOD(A2-A1,1),"hh")&" hours
"&TEXT(MOD(A2-A1,1),"hh")&" minutes "&TEXT(MOD(A2-A1,1),"hh")&" seconds"

gives
0 years 2 months 17 days 01 hours 01 minutes 01 seconds

which is, I think, the right answer. [I think your answer is a day
adrift.?]


Sorry, too much of a hurry, some of the above was wrong, of course.

=MOD(A2-A1,1) formatted as hh" Hours" mm" Minutes" ss" seconds" gets the hh
mm ss part right

For the days part I think it needs (or otherwise it goes wrong when the
earlier date has a later time of day):
=DATEDIF(B1,B2,"y")&" years "&DATEDIF(B1,B2,"ym")&" months
"&DATEDIF(B1,B2-IF(MOD(B1,1)MOD(B2,1),1,0),"md")&" days "

I haven't yet been able to get the two parts to combine, as I couldn't get
TEXT() to work with the format I wanted for the time part (even when I
corrected the places above where I'd erroneously put hh when I meant mm &
ss).
--
David Biddulph




  #6   Report Post  
Posted to microsoft.public.excel.misc
Pontoon
 
Posts: n/a
Default I need to find the yy/mm/dd AND hh:mm:ss between 2 time stamps

Thanks David,
It doesn't matter that the two parts of this are in differnet cells... I can
just put the different portions of this is adjacent cells and align them
appropriatley.

Many thanks for your help with this. I doubt whether I woudl have managed to
figure this out myself.

Cheers


Pontoon
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
sum time in hh:mm:ss format steven Excel Discussion (Misc queries) 1 May 17th 06 05:17 PM
Negative time value hh:mm:ss Jelinek Excel Discussion (Misc queries) 5 March 20th 06 04:48 PM
Time for some help (Please!) Dean Excel Worksheet Functions 5 May 19th 05 06:14 AM
can you input time (hh:mm:ss) without having to input the colon i. Lexicon Excel Discussion (Misc queries) 4 January 11th 05 02:09 PM
Time - converting HH:MM:SS to Minutes Noel S Pamfree Excel Worksheet Functions 3 January 8th 05 04:26 PM


All times are GMT +1. The time now is 05:46 PM.

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"