Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a date to a string in Google Sheet

I am trying to figure out how to convert a date into a string in a google sheet.

I have one date field that has varying formats. I want create another column that's literally just the same but as a text. For example, if I had the following data

date       date_as_string
12-05-2016 '12-05-2016
12/5/2016  '12/5/2016
2016-12-10 '2016-12-10

Where the ' is just to denote that it is a string note a date.

like image 507
Vincent Avatar asked Nov 29 '16 03:11

Vincent


People also ask

How do I convert data to text in Google Sheets?

The simplest way to convert numbers to strings in Google Sheets is to use the TO_TEXT() function. It only requires you to point to the cell containing the number to be converted to string. It will preserve the formatting that you can see in that original cell.

How do I separate date and text in Google Sheets?

Method 1: Use SPLIT Function On cell B2, type =SPLIT(A2, “ ”). This will automatically write the date in cell B2 and the time in cell C2. Don't forget the space between the “ ”.


3 Answers

You can use the TEXT function.

=Text(cellReference, "mm-dd-yyyy")
like image 114
Alexander Avatar answered Oct 22 '22 05:10

Alexander


Use the TEXTJOIN function. Give an empty delimiter, TRUE for the ignore empty, the referenced cell as text1, and don't supply anything for text2.

=TEXTJOIN("",TRUE,A1)

Done.

like image 50
Chindraba Avatar answered Oct 22 '22 04:10

Chindraba


=TEXT(now(),"yyyy-MM-dd hh:mm:ss")

enter image description here

This cell is now a string.

like image 17
Alan Avatar answered Oct 22 '22 04:10

Alan