Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting a date and time from 2 columns

Status
Not open for further replies.

Sahubba

Programmer
Mar 16, 2011
108
US
Hello,

I was wondering is there a way to subtract a date+time from to columns and have the results in seconds?

Example;
F2 I2 J2
Oct 8, 2012 4:17 PM Oct 15, 2012 1:04 PM Results in seconds

I am using excel 2007
above are how the dates and time are formatted


Thank You for your help.
 
hi,

Simply take the difference between the two date/time values. The result is in DAYS.

Then simply convert DAYS to SECONDS: (DAYS*24*60*60)

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hello,
Just a simple subtraction like F2-I2 does not work for me.
Is there another way I can do the subtraction?
 
Then you don't have REAL DATE TIME VALUES! You merely have TEXT!

Convert your TEXT to REAL DATE TIME VALUES using Data > Text to columns choosing the MDY date conversion conversion for each column

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hello,
I did as you explain above and still there is no difference.
 
I get 6.865972222 days

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
For some reason the cell format wont change.
I even tried format cell and choose a custom formating and nothing happens unless I delete the cell contents and enter the date again.

I paste the dates into excel so I am not too sure if that has anything to do with it.
 
Please post the data that is in

F2
I2
J2

on separate lines here so we can be sure of what we are referring to.


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Sure

F2 I2 J2
Oct 8, 2012 4:17 PM Oct 15, 2012 1:04 PM Would be the results

 
So you are saying that ...

F2 contains F2 I2 J2

and I2 contains Oct 8, 2012 4:17 PM Oct 15, 2012 1:04 PM Would be the results

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
and nothing is is J2


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
No Sorry
F2 Oct 8, 2012 4:17 PM
I2 Oct 15, 2012 1:04 PM
J2 Would be the results


But I got it to work.
I ended up exporting this excel file to access and converting the data types to a Date/Time and then exported it back to excel.


Dont know what went wrong with the paste.
But it works now.

Thanks for you time and help!

 
You could also do a format change on the text, converting it into the Date standard.

J2 = (TEXT(I2,"mmm d, yyyy h:mm am/pm")-TEXT(F2,"mmm d, yyyy h:mm am/pm"))*24*60*60



OCD, it’s not obsessive if you can control it…
 
@yoo,

Why change a DATE/TIME value to TEXT, that then must be converted back to DATE/TIME to do the arithmetic???



Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top