convert string to date and time

wxornot

New Member
Joined
Oct 20, 2005
Messages
30
I have the string in a cell:

20070728000000

This is suppose to represent 7/28/2007 12:00:00 AM

Given these formulas I can get the date and time.

=DATE(MID(B4,1,4),MID(B4,5,2),MID(B4,7,2))
=TIME(MID(B1,9,2),MID(B1,11,2),MID(B1,13,2))

How can I merge the above formulas into one field so date and time are together?

thanks.
 
Last edited:

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
You were almost there.

=DATE(MID(B4,1,4),MID(B4,5,2),MID(B4,7,2))+TIME(MID(B4,9,2),MID(B4,11,2),MID(B4,13,2))

You will also have to format the cell to display the time as part of the date.
 
Upvote 0
With
A1: 20070728123400

This regular formula returns the date/time value of that cell:
B1: =--TEXT(A1,"0000\-00\-00\ 00\:00\:00")

Format the formula cell to display Date and Time

In the above example, the formula resolves to 2007-07-28 12:34:00

Does that work for you?
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,158
Members
452,892
Latest member
yadavagiri

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