Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically convert date text to correct date format using Google Sheets

I'm trying to convert date from "text" to correct format. It is logged to Google Spreadsheets and I'm unable to use it to plot graphs.

This is the text format: February 3, 2018, at 11:21 AM

Time is not relevant, all I need is the date converted: DD/MM/YYYY.

I found a similar question where Gary's Student answered with a formula that looks like this for a different format:

=DATEVALUE(SUBSTITUTE(A1,MID(A1,FIND(" ",A1)-2,2),""))

(link to that question)

How can I use above formula (or something similar) so that text is converted to date?

Thanks in advance.

like image 583
TheIdiot Avatar asked Feb 17 '18 09:02

TheIdiot


People also ask

How do I convert text to date format in Google Sheets?

Using DATEVALUE and TO_DATE Function to Convert Text to Date in Google Sheets. We can use a combination of the DATEVALUE and TO_DATE functions to convert a date that is originally in TEXT format to one that is in the Google Sheets DATE format.

How do I convert text to date in spreadsheet?

Convert text dates by using the DATEVALUE function Select a blank cell and verify that its number format is General. Click the cell that contains the text-formatted date that you want to convert. Press ENTER, and the DATEVALUE function returns the serial number of the date that is represented by the text date.

How do I convert a date value to a date in sheets?

The syntax of the DATEVALUE function in Google Sheets is as follows: DATEVALUE(date_string) The date_string argument is the text representation of the date that you want to convert to a date value.


2 Answers

The , at portion of the string is keeping Google Sheets from recognizing it as a datevalue. Just remove it with the substitute function and wrap in datevalue function like so: =DATEVALUE(SUBSTITUTE(A1,", at",""))

To format as DD/MM/YYYY just go to custom formatting and set it to look like the following: enter image description here

enter image description here

like image 91
Torey Price Avatar answered Nov 19 '22 18:11

Torey Price


=DATEVALUE(JOIN("/", LEFT(D5,2), {MID(D5,4,2), RIGHT(D5,4)}))

where D5 contains for example: 25.06.2019

which script converts to datevalue: 43641

Dateformat is as dd.MM.YYYY converted to dd/MM/YYYY and then converted to datevalue.

Google sheet's documentation helps:

DATEVALUE, JOIN, LEFT, MID, RIGHT

Datevalue is useful for organizing rows of data by date correctly.

like image 23
J-ho Avatar answered Nov 19 '22 18:11

J-ho