Convert string to a epoch time in Excel - excel

I am trying to convert string in following format: 20130817T140000Z(17th Aug 2013 at 14:00) to epoch time (seconds since 1970) in an MS Excel 2013.
Tried cell formatting, but it doesn't work with T and Z or the format in general.

This will convert your date into somethign Excel will understand, If you have your date in Cell A1, Then convert that into Epoch Time
=(DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2)) + TIME(MID(A1,10,2),MID(A1,12,2),MID(A1,14,2))-25569)*86400)

Try this:
A1=20130817T140000Z
A2=DATE(LEFT(A1,4),MID(A1,5,2),MID(A1,7,2))
A3=(DATEDIF("01/01/1970 00:00:00",A2,"D")+TIME(MID(A1,10,2),MID(A1,12,2),MID(A1,14,2)))*24*60*60
A1 is your input date as text, A2 is a formatted date, and A3 is a seconds difference between your date and epoch start date.
Useful link
Update: based on #user2140261 suggestions.

Assuming the string to convert is in cell B1 you can use the following with a custom format on the cell to get the date/time.
=DATE(MID(B1,1,4),MID(B1,5,2),MID(B1,7,2))+TIME(MID(B1,10,2),MID(B1,12,2),MID(B1,14,2))
The custom format is:
dd/mm/yyyy hh:mm:ss

This will get you the date with accuracy to the minute. You can follow the pattern to get seconds if necessary.
=DATE(VALUE(LEFT(A1,4)),VALUE(RIGHT(LEFT(A1,6),2)),VALUE(RIGHT(LEFT(A1,8),2)))+VALUE(RIGHT(LEFT(A1,11),2))/24+VALUE(RIGHT(LEFT(A1,13),2))/(24*60)

You could use this version to convert your string to Epoch time
=(TEXT(LEFT(A1,8)&MID(A1,10,6),"0000-00-00 00\:00\:00")-25569)*86400
This uses TEXT function to convert your string into a string that looks like a valid date/time - when you subtract 25569 (1/1/1970) that will co-erce that string to a valid date/time and the result can be multiplied by the number of seconds in a day to get Epoch time

Related

separating date and time from datetime column in excel

how to separate date and time from datetime column if you have the format as below :
click here to view image
I am trying int(datetime column) for fetching date ; Datetime column - int(datetime column) for fetching time column
Your formula cannot work because your data is a text string (note that it has a letter included) and not a number.
So first convert the string into a "real" time with:
=substitute(a2,"T"," ")
You can then use:
Date: =INT(SUBSTITUTE(A2,"T"," "))
Time: =MOD(SUBSTITUTE(A2,"T"," "),1)
and be sure to format the results as desired:
If your column is formatted true date then use to separate date
=TEXT(A1,"yyyy-mm-dd")
For time
=TEXT(A1,"hh:mm:ss")
If data is in text string or output by TEXT() function then try below functions.
for date =TEXT(FILTERXML("<t><s>"&SUBSTITUTE(A1,"T","</s><s>")&"</s></t>","//s[1]"),"yyyy-mm-dd")
for time =TEXT(FILTERXML("<t><s>"&SUBSTITUTE(A1,"T","</s><s>")&"</s></t>","//s[last()]"),"hh:mm:ss")
For date
=LEFT(A2,FIND("T",A2)-1)
For time
=RIGHT(A2,LEN(A2)-FIND("T",A2))

How do I convert this date text to a date field in excel?

I have a date that looks like this text. 17-OCT-16 03.24.11.000000000 AM
I need to format that text into a date that I can then manipulate. Ultimate I want to transform that time to millis from epoch but I'm not sure if that's even possible
Its definitely possible, you can make use of DATEVALUE and TIMEVALUE function which convert a time or date in string format to date/time format:
=DATEVALUE(LEFT(A1,9)) + TIMEVALUE(SUBSTITUTE(MID(A1,11,8), ".", ":")&MID(A1, 19, 9))
This will give you a single number (42660.1417939815) in this case which is the number of days since 1/1/1900 (including milliseconds)
It should just be some simple maths to get total milliseconds

How to convert long minutes to hours in excel

I need a formula in excel to convert minutes to hours. Until now came the following formula:
=A1/1440
So, 180minutes its converted to 03:00, when formatted as hh:mm
But, i need also to convert long minutes, like 1600. In this case, the formula converts to 02:40, when it should show 26:40.
Any ideas?
You can try
=INT(A1/60)&":" &MOD(A1,60)
and =TEXT(FLOOR(A1/60,1),"00")&":"&TEXT(MOD(A1,60),"00") for Format hh:mm
Use exactly the same formula you are using now, but change the display format to:
[h]:mm:ss
That will display in the format you want AND allow you to perform operations on the values.
( With format showing in the top of the time columns)
[h]:mm:ss hh:mm:ss Equal?
=1600/1440 =1600/1440 =G23=F23
=F23+1600/1440 =G23+1600/1440 =G24=F24
Gives
[h]:mm:ss hh:mm:ss Equal?
26:40:00 2:40:00 TRUE
53:20:00 5:20:00 TRUE

converting text date with am/pm time into 24 hour time in excel non VBA

I am looking to convert a text time with a and p on the end into usable time in excel I have used the mid function and I does not seem to recognize the a/p and makes all the times am unless its 12--. Then it will return a PM time. I have used the Mid function and have searched the threads.
Times in the database look like
10/ 1/14 5:14P
These are text
I have used the mid function
=TIMEVALUE(MID(B6,9,6))
Returning
5:14:00 AM
when the time should be a Pm or 17:14
Help would be appreciated
Thanks
Try this :
=SUBSTITUTE(SUBSTITUTE(A1,"A", " AM"),"P", " PM")+0
where A1 has the value.
Format the cell to the kind of date / time / datetime format that you want ; formatting it to :
dd-mm-yyyy h:mm:ss AM/PM
will display :
10-01-2014 5:14:00 PM

Convert milliseconds to date (in Excel)

I have a row in excel with the following data: 1271664970687 (I think it's the number of milliseconds from 1970...).
I would like to have addition row that will show it as date/time.
Converting your value in milliseconds to days is simply (MsValue / 86,400,000)
We can get 1/1/1970 as numeric value by DATE(1970,1,1)
= (MsValueCellReference / 86400000) + DATE(1970,1,1)
Using your value of 1271664970687 and formatting it as dd/mm/yyyy hh:mm:ss gives me a date and time of 19/04/2010 08:16:11
See Converting unix timestamp to excel date-time forum thread.

Resources