DateDif

  • Thread starter Thread starter SpecialD
  • Start date Start date
S

SpecialD

Hello! I'm new here!

Is it possible to calculate these two dates and times

cell A1 is 3/4/2004 10:00AM
cell A2 is 3/9/2004 11:00am

If it's possible, how would you accomplish it?

thanks..
 
Hi SpecialD!

What do you want to calculate? I'm assuming you want the difference.

You can get the difference in number of days using DATEDIF which strips off
the non-integer part of the date serial number (the time bit)

=DATEDIF(A1,A2,"d")
Returns 153

But if you use A2-A1 you will get the difference including accounting for
the time element:

=A2-A1
Returns 153.041666666672

And welcome!!

--
--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.

(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
Thank you! but how would you calculate the two cells with time and dat
in the same cell?

As you can see, cell A1 is 3/4/2004 10:00AM and cell A2 is 3/9/200
11:00AM. I want the result in cell A3 equals to 5 DAYS 1 HOUR. Is i
possible to calculate it like that? If it is, how would you do it?

Thanks again!!
 
Hi
try
=DATEDIF(INT(A1),INT(A2),"d") - (MOD(A2,1)<MOD(A1,1)) & " DAYS " &
(MOD(A2,1)-MOD(A1,1) + (MOD(A2,1)<MOD(A1,1)) )*24 & " HOURS"
 
thank you! that code works great! now, all I have to do is write a cod
to blank out the AM / PM.

THANKS AGAIN!
 
Hi
no need for code, just format the target cell with an appropiate date
format ('Fomat - cells'). e.g.
hh:mm
 
Thanks Frank and everyone for helping. I'm still having difficult
converting the time. How do you convert 2.89879877 HOURS to HH:MM?

thanks again everyone.
 
Back
Top