I have a text value that looks like this: 2019-03-25T06:05:00-07:00. The general format is yyyy-mm-ddThh:mm:ss-GMT. I don't care about the GMT part. I am trying to use this text field to make time series scatter plots in excel.
I want to convert it to a timestamp as simply as possible. I currently do this using a bunch of formulas:
Input: 2019-03-25T06:05:00-07:00
Extract parts of time individually: =value(mid(input_cell,12,2))
Use date() and time() to get timestamp types
Add them together per this answer: https://stackoverflow.com/a/41164517/11163122
Use custom formatting to get a timestamp value
Output: 3/25/2019 6:05:00 AM
In total this took me 8 cells and custom formatting. This is too complicated. What is a simpler/more elegant way to do this?
You can use:
=--REPLACE(LEFT(A1,19),11,1," ")
and format as desired
Turns out the timestamp type is ISO 8601: https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations
This led me to this answer: https://stackoverflow.com/a/26315881/11163122
Using the formula there, I found this to be a sufficient solution. If anyone out there has a better method, please speak up! :)
Related
I want to subtract the time in text format
like: 10.51 - 2.15 (means 10hrs 51min - 2hrs 15min)
Now I using Min-Min and then convert to Hrs in text format, but have any wonderful code that I no need convert to Min? just Hrs-Hrs.
=CONCATENATE(INT((textMin)/60),".",MOD(INT(textMin),60))
I don't use time format or ":" because have a lot data to key in, number pad is good for key in much data.
Thanks a lot!
Several ways to approach this.
Use Find and Replace to replace . with :, then use simple subtraction
leave the data as you input it and use a formula to convert the decimals into time values
=TIME(INT(A1),MOD(A1,1)*100,0)-TIME(INT(B1),MOD(B1,1)*100,0)
like here:
Or use
=SUBSTITUTE(A1,".",":")-SUBSTITUTE(B1,".",":")
I've searched on the internet and couldn't find. The only solution I found was to download kutools, and I can't do it.
I've made a macro that gets some values from an intranet, but I need the type of cell to be in date so I can work around it and filter it.
I don't know if I explained it correctly, and sorry if my english isn't the best.
I made an image to better explain it.
How it currently is / How I want it to be:
You can use the DATE and TIME functions to convert your text to date/time format.
=DATE(2018,MID(A2,4,2),LEFT(A2,2))+TIME(MID(A2,7,2),RIGHT(A2,2),0)
Using Filters:
How can we convert YYYYWWD format date into normal date format YYYY-MM-DD using Syncsort?
I think you are out of luck. Syncsort has the same features as DF/Sort and according to this - https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.2.0/com.ibm.zos.v2r2.icea100/ice2ca_DFSORT_data_formats.htm - Df/sort does not recognise a YYYYWWD date format. It may be possible however to so the maths yourself with Syncsort, but I can;t see any way to do this.
YYYYWWD is a non-standard date format, so this is not really surprising. The best solution (if you cannot get the data in the correct format initially) would be to process the data with REXX before sorting it, if the volumes of data allows this.
Unless, of course, this is a 'homework' question and you have to use Syncsort? (which would imply that it is possible)
I needed help as I am trouble with this recurring problem.
I have following date formats. American date format:
8/30/2013
11/1/2014
1/12/2014
For 8/30/2013 , I write =DATE(RIGHT(B2;4);LEFT(B2;1);MID(B2;3;2)), and I get it as "2013-08-30". For the other dates, I have to manually rewrite them again and again.
How can I write in one line to get 8/30/2013 or 10/12/2014 in a final date result like "2013-xx-xx?
if all entries are dates, you can use Text function:
=TEXT(B2, "yyy-mm-dd")
hope this helps.
Since you used string manipulation formulas and it worked for your first date, I believe that the date is actually text format.
As such, I would suggest using FIND to get the positions of / like this:
=DATE(RIGHT(B2;4);LEFT(B2;FIND("/";B2)-1);MID(B2;FIND("/";B2)+1;FIND("/";B2;FIND("/";B2)+1)-FIND("/";B2)-1))
It's quite long, I admit, but it's quite difficult to get substrings between two specific characters. If the year is always in that format, then you can use a slightly shorter formula:
=DATE(RIGHT(B2;4);LEFT(B2;FIND("/";B2)-1);MID(B2;FIND("/";B2)+1;LEN(B2)-5-FIND("/";B2)))
I am currently trying to convert yyyymmdd type of date to a ddmmyyy format.
I've tried using DATE function and something like this:
=DATE(LEFT(A3;4);MID(A3;5;3);RIGHT(A3;7))
Original date for this function is 20120401 but the formula returns: 16.12.2104.
I've tried using functions YEAR, MONTH and DAY instead of LEFT, MID and RIGHT but that's not the right way.
I also tried using DATEVALUE but since Excel probably doesn't recognize yyyymmdd as a date, it gives me a #VALUE! error.
I've found a couple of solutions for SQL but it isn't my strong side yet - and this should be achievable easily in Excel.
Is there a way to do this in Excel?
Applying =DATE(LEFT(A3;4);MID(A3;5;3);RIGHT(A3;7)) to 20120401 in A3 is effectively to reassemble the component characters as below on the left:
These effectively become converted as on the right.
The solution was simply to exclude the digits highlighted red with:
=DATE(LEFT(A3;4);MID(A3;5;2);RIGHT(A3;2))
but the locale might have been a factor and when dealing with date serial numbers and/or what appears to be a date but is a string various other issues might have been involved.
Consider:
=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))