'Apps Script - get a timestamp from a cell containing a date and a cell containg a time
I have a sheet containing 2 columns:
Date | Time
01/01/2022 | 12:01
I would like to create a timestamp from the sheet in Google Apps Script without having to go through the creation of an additional column that would add A and B.
I have tried different ways, but I have not found something good enough.
Of course, when I do :
const ss = SpreadsheetApp.getActiveSpreadsheet();
const ws = ss.getSheets()[0]
const date = ws.getRange(A2).getValue();
const time = ws.getRange(B2).getValue();
const timestamp = date + " " + time;
it is not working..
Any idea about an elegant way to work on that. Thank you very much.
Florent
Solution 1:[1]
const timeStamp = ss.getRange("A2").getDisplayValue() + " " + ss.getRange("B2").getDisplayValue();
getDisplayValue() instead, so it gets each value as a string.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | onit |
