Excel DateValue = Formatting - excel

Looking to convert the following 2015-10-07T23:59:59 into something that Excel actually recognizes as a date so I can then graph/chart with this data... I tried using datevalue and custom formatting but can't get the syntax quite right.

To get datetime from your string, you only need to replace T with space, convert to numeric and apply appropriate cell format.:
=1*SUBSTITUTE(A1,"T"," ")

I dont know if Excel can understand that type of format date, you should try to write your own custom function to get it in the format that you want.

How about yyyy-mm-ddThh:mm:ss for the custom format?

If the timestamp isn't needed, use =DATEVALUE(LEFT(A1,10)). If it is needed, then use =DATEVALUE(LEFT(A1,10))+TIMEVALUE(RIGHT(A1,8)). (Where cell A1 contains the datetime string you are trying to parse).
This will return the Julian date value (E.g. 42284 for the day, 42284.96 for day & time) which you can then apply Excel's built in date formatting to, it will also work for charts and pivot table grouping.

Related

Date incorrectly converts into required format (dd/mm/yy) in excel

Hi I know lots of similar questions can be found here, but I am still facing this problem:
I have a table with one column called Dates with some values shown below:
12/2/2021
11/2/2021
10/2/2021
9/2/2021
8/2/2021
7/2/2021
6/2/2021
5/2/2021
4/2/2021
3/2/2021
2/2/2021
1/2/2021
31/01/21
30/01/21
When I try to convert it using Format cells either by selecting category as Date or adding custom category as dd/mm/yy, excel treat the dd/mm/YYYY values as mm/dd/yy.
So for example, instead of treating 1st row as 12 February, excel thinks of it as 2 December.
I also tried convert text to columns by going to DATA and setting it as DMY but it doesn't solve the problem.
Any help is really appreciated.
Try this formula:
= DATE( YEAR(A1), DAY(A1), MONTH(A1) )
If the values have any space character, try this one:
= DATE( YEAR(TRIM(A1)), DAY(TRIM(A1)), MONTH(TRIM(A1)) )
Assumptions:
All the dates were originally DMY
Your windows regional settings short date format is MDY
You will need to convert to a proper date
If the value is text, then it will be in DMY format and you can extract the sections and convert to a date
If the value is numeric, then it has been converted improperly and you need to reverse the month and day part
Given those assumptions, the following formula should work.
I am using the LET and FILTERXML functions which are available in Excel Office 365 Windows versions.
If you don't have that version of Excel, you can still do this with formulas but it will be more complex. Or you can use VBA.
=IFERROR(DATE(YEAR(A1),DAY(A1),MONTH(A1)),
LET(x,FILTERXML("<t><s>" & SUBSTITUTE(A1,"/","</s><s>")& "</s></t>","//s"),
DATE(INDEX(x,3)+IF(INDEX(x,3)<30,2000),INDEX(x,2),INDEX(x,1))))

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

Using a CDate in a Countifs function

I was wondering if there was a way to use the CDate function in a countif statement? I'm trying to find dates less than 2 weeks old, am and currently using this statement:
=COUNTIF(CDATE(Table1[Date Closed]),">=" &TODAY() - 14)
I need to turn the Date Closed of the table into actual dates without changing the table (right now they're in the format 13-Mar-2018 but as text format).
Is there a way to do this within the Countif function or am I going to have to do a a VBA code to first change the dates?
Thank you!
=SUMPRODUCT(--(DATEVALUE(Table1[TextDates])>=(TODAY()-14)))
Although I do wonder why you can't have dates as real Excel dates, rather than text strings
Set up your table and insert a column (you could hide the original or place the new column at the end or next to the original) and convert the text date to a date via the DATEVALUE() function.
See reference:
https://support.office.com/en-us/article/datevalue-function-df8b07d4-7761-4a93-bc33-b7471bbff252
You may want to apply format to the new cell/column to look like a date.
Set up your table for "Using structured references with Excel tables."
See reference:
https://support.office.com/en-us/article/using-structured-references-with-excel-tables-f5ed2452-2337-4f71-bed3-c8ae6d2b276e
Count dates based on your condition.
See reference:
https://support.office.com/en-us/article/count-numbers-or-dates-based-on-a-condition-976d0074-245d-49e6-bf5f-1207983f82ed

Change date format in excel

I am getting data in a CSV file with data column having format e.g. 1987-09-17T00:00:00.000-06:00.
When I apply date formatting on it to say DD/MM/YYYY, it doesn't change to 17/09/1987.
Is there a way to achieve this?
Thanks!
Excel will assume it is text because it is not in a format it recognises as being a date. You could use LEFT() and MID() functions to split out the parts you want as arguments in the DATE() function. Eg
=DATE(left(A1,4),(MID(A1,6,2),MID(A1,9,2))

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