Gabriel Piffer Gabriel Piffer - 1 month ago 19
Javascript Question

Add a timestamp programatically

I am trying to create a code to Google Spreadsheets . In VBA code it is very simple. My goal is, when a particular cell is filled , another cell displays the date and time of completion .

In VBA:

Function DateTime()
DateTime = NOW
End Function

Answer

Based on your most recent comment stating that you want to call a custom function from the Google Sheet frontend, all you will need in your Script Editor (backend) is:

function timeStamp() {
  return new Date();
}

You can then call that function from a formula in your Sheet, very similar to what you wrote already:

=IF( ISBLANK(A1), "", timeStamp() )
Comments