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.
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.
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 “ ”.
You can use the TEXT function.
=Text(cellReference, "mm-dd-yyyy")
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.
=TEXT(now(),"yyyy-MM-dd hh:mm:ss")
This cell is now a string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With