Using moment in Transformer

Hi all,

I've been trying to use the moment function in the Transformer of an SQL query for days now and for some reason it won't work. The weird thing is, I contacted support that showed me a screenshot of a query that worked which I copied and pasted with no luck.

Is there a very simple way to get the difference between 2 dates in the transformer ?

Here is my code so far (that doesn't work):

NB : the SQL query gets a table with a column called "golive" that has one date in it

let myDate = new Date();

let d1 = moment(myDate);
let d2 = moment(data['golive'][0]);

let difference= Math.abs(d2-d1);
let result = difference/(1000 * 3600 * 24)

return result

Even when I do this, I get a "now rows to display" :

let myDate = new Date();

let d1 = moment(myDate);

return d1

Any ideas as to why that won't work ?

Thanks !

Hi @Charlie. Thanks for reaching out! It sounds like you're referencing the moments difference function, this seems like it would be a good use case for moment().diff() based on what you've shared. Here's the docs for that function: I think it would be helpful to see what the data from your SQL query looks like. Can you share that information and we'll take a look and see how we can help? Thanks!