Time and date from string to calculation

mtheriault2000

Well-known Member
Joined
Oct 23, 2008
Messages
826
Hello

I got 2 string that represent time as (yyyymmdd hh:mm:ss)

t1 = "20110922 18:57:00"
t2 = "20110922 19:00:02"

Now, I need to calculate

(T2- T1) + T2

What is the step that I need to accomplish to get the result equal to
"20110922 19:03:00"

How do I transform a string date to a string number

Martin
 
Re: Resolved: Time and date from string to calculation

You might want to study my 3-Format-Statements solution... it is much more compact and, in my view, easier to read/maintain (once you understand the @ metacharacter usage that is).

Good Idea
I did post my solution before reading yours. Il like it because your format is well defined

Many thanks
Martin
 
Upvote 0

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If your date are in A1 and A2:

Try this formula:
Code:
=(DATE(LEFT(A2,4),MID(A2,5,2),MID(A2,7,2))+TIMEVALUE(RIGHT(A2,8)))*2-DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2))-TIMEVALUE(RIGHT(A1,8))

Format date as: "yyyymmdd hh:mm:ss"
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,582
Messages
6,179,670
Members
452,936
Latest member
anamikabhargaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top