Gabriel Piffer Gabriel Piffer - 1 year ago 144
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 .


Function DateTime()
DateTime = NOW
End Function

Answer Source

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() )
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download