1

I have an Alasql Database that looks like this:

results
Name      Recieved
Bill      10/11/17 7:42 AM
Susan     10/05/17 3:43 AM
Sarah     10/04/17 2:08 PM

I'm trying to update it to convert the Recieved table and convert it into a unix timestamp.

This is what I tried:

alasql(`UPDATE result SET Recieved = ${new Date(Recieved).getTime()}`);

I get this error in Node:

ReferenceError: Recieved is not defined

How do I use the existing Recieved data from the database and perform mutations on it?

Jordash
  • 2,926
  • 8
  • 38
  • 77

1 Answers1

1

If anyone runs into this problem alasql allows for custom functions like this:

alasql.fn.toTimestamp = function(date) {
  return new Date(date).getTime() / 1000;
}
alasql(`UPDATE result SET Received = toTimestamp(Received)`);
Jordash
  • 2,926
  • 8
  • 38
  • 77