Excel convert decimals to Time - excel

I have a date/time field extracted from SQL.
Value is 2016-08-25-00.56.09.861000
I want to just get the time out of this to check if the time is before or after 9am.
I have extracted the time:
=RIGHT(A1, LEN(A1)-11)
Is there a way to then convert this to time format 00:59:09 that I can then use to compare against 09:00:00?
Thanks

Try this
=TIME(MID(A1,FIND(".",A1,1)-2,2),MID(A1,FIND(".",A1,1)+1,2),MID(A1,FIND(".",A1,1)+4,2))
after that convert result to hh:mm:ss by using format cell

Since your data in A1 is a defined format, you can use:
=TIMEVALUE(SUBSTITUTE(MID(A1,12,8),".",":"))
And format the cell containing this formula as a time.

Related

Date-text is not converting to real date

I had a bad time trying to import some excel data, then I found that there's a problem with a date field.
I thought the field is string-date text, but when I try to convert it to real-date, not all data convert well Here's a sample below
I tried to format cells, didn't work. Then tried
1- DATEVALUE and VALUE functions
2- ADD zero
3- DELIMITED text to columns
but nothing appears to work. What is this type of data?? and how to convert to real text?
appreciate your help.
In B2 enter:
=IFERROR(VALUE(A2),DATE(RIGHT(A2,4),MID(A2,4,2),RIGHT(A2,2)))
EDIT#1:
Fixed Formula and format:
=IFERROR(VALUE(A2),DATE(RIGHT(A2,4),MID(A2,4,2),LEFT(A2,2)))
If one has textjoin:
=--TEXTJOIN("/",,FILTERXML("<a><b>"&SUBSTITUTE(TEXT(A1,"mm/dd/yyyy"),"/","</b><b>")&"</b></a>","//b["&{2,1,3}&"]"))
If not then parse the TEXT:
=DATE(RIGHT(TEXT(A1,"mm/dd/yyyy"),4),MID(TEXT(A1,"mm/dd/yyyy"),4,2),LEFT(TEXT(A1,"mm/dd/yyyy"),2))
Solved it!!
I needed to change my machine date format, I am not certain but here's what I think was the problem.Because the data was a string-date not a real date, so excel took format of my machine which was mm/dd/yyyy. so for the first date 20/01/2000, excel cannot put 20 as a month when I try to change format or run (text to column) or result in error in DATEVLUE and VALUE, so lots of dates didn't get formatted or resulted in error. On the other hand, the second date, 07/02/2002, can be formatted and functions work well.
So, changing my machine format to dd/mm/yyyy solved the issue and data converted with simple Text to Column.
Big Credit for #ScottCraner

Change date in excel

I am trying to change the date format of my cells in excel to another date format. Currently it is in this format: apr, 10, 2017 01:58:24 PM. I would like to have it in a normal format like dd-mm-yyyy without the time, but I can not get it to work with the formatting in excel.
Thanks in advance,
Kester
You could use this:
=(MID(A2,FIND(",",A2)+2,FIND(",",SUBSTITUTE(A2,",","#",1))-FIND(",",A2)-2)&"-"&LEFT(A2,FIND(",",A2)-1)&"-"&MID(A2,FIND(",",SUBSTITUTE(A2,",","#",1))+2,LEN(A2)))*1
Which is basically a bit of string manipulation (and some substitution of , to # to help) to put it in the generic format 'd-m-y h:m:s t', which excel understands, then multiply the string by 1 to force into a number (in this case 42835.58222); which you only have to format as date (important!):
Edit: Per comments, the first comma doesn't actually exist, so the revised formula:
=(MID(A2,FIND(" ",A2)+1,FIND(",",A2)-FIND(" ",A2)-1)&"-"&LEFT(A2,FIND(" ",A2)-1)&"-"&MID(A2,FIND(",",A2)+2,LEN(A2)))*1
With data in A1, in B1 enter:
=DATE(MID(A1,10,4),MATCH(LEFT(A1,3),{"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"},0),MID(A1,6,2))
and apply desired formatting:
(this results in a genuine Excel date that can be used in sorts, calculations, etc.)(this assumes that the day field is always two digits)(if your month list is in a language other than English, edit the month list)

Convert General to Date in Excel

I have a date field where the format is (example) 20170101.
When I try to convert this field to short date, it comes up as "###".
I need the date in the format of 1/1/2017.
Can someone help?
Thanks!
The data is not a date but a number and by simply changing the format will try to return a date that is 20,170,101 days from 1/1/1900. And Excel stops recognizing dates after 12/31/9999. This would be well beyond that, roughly 45 thousand years beyond that.
you can use a helper column with the following formula:
=--REPLACE(REPLACE(A1,7,0,"/"),5,0,"/")
Format it as desired.
Then you can copy paste just the value over the original.

Error in Date Cell in CSV

I have a date column with YYYY/MM/DD HH:MM:SS AM/PM format in Excel file(xlsx).
But when I am trying to save it in CSV format then the values in date column converts to MM/DD/YYYY HH:MM .
But I want to keep the values in the same format.
Please help me to solve this and Thanks in advance.
Use Custom format as yyyy/mm/dd hh:mm:ss AM/PM in Type text box and save as csv should work
This is a well known problem with CSVs. You can't provide any sort of formatting information about the column to excel, and so it takes liberties with dates. One way around it is to trick excel into processing the column as a string value, instead of a date value, by wrapping it in ="", so an example csv might look like this:
Sample.csv
Name,Date,Note
Foo,="2014/12/03 12:14:15 AM",Bla
Bar,="2012/11/13 3:14:15 PM",Bla Bla
Excel will preserve the date format because it will process it as a string value, so it will not modify it in any way.

How can I transfer a date format like 2014/02/13/19:57:00 to an excel readable date format?

I have tried and change 2014/02/13/19:57:00 to 2014/02/13 19:57:00, but excel still cannot detect this as readable date format so I cannot change to another date format in excel. I have a whole column of date like this one.
So what can I do in excel?
Thanks.
You should be able to use something like this:
=SUBSTITUTE(A1,"/"," ",3)*1
This replaces the 3rd occurrence of / and replaces it with a space. The *1 then tells excel to convert it into a number (if possible). Formatting the result as date time should give you the datetime you are looking for.
If for some reason that doesn't work, this formula can be used instead:
=(DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+RIGHT(A1,8))*1
That one takes bits of the date and sticks the time. Again, format the cell as datetime.

Resources