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 lit
=TEXT(now(),"yyyy-MM-dd hh:mm:ss")
This cell is now a string.
You can use the TEXT function.
=Text(cellReference, "mm-dd-yyyy")
I don't understand why you need this. Just figured out that there's no way to detect the format of dates in google sheets. But you may use getDisplayValues property. Paste this code into script editor:
function repeatAsText(A1Notation, sheet) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
if (sheet) { sheet = ss.getSheetByName(sheet); }
else { sheet = ss.getActiveSheet(); }
var range = sheet.getRange(A1Notation);
return range.getDisplayValues();
}
and then use it as ususl formula:
=repeatAsText("A1:A3")
A1Notation -- string like "A1" or "B3:AD15".
sheet -- name of sheet, like "Sheet1". It is optional, use ActiveSheet if omitted
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.
to concatenate text to date you can do this:
=CONCATENATE("today is: ", TEXT(HOY(), "dd-mm-yyyy"))