Get the difference between dates

I've tried DATEDIFF and I've tried using moments but I can't seem to make anything work. Can someone help please?

I have two dates and would like to filter my SQL results to when the dates are the same day.

Like DATEDIFF(day,CONVERT(datetime, [What date are you not available?]),CONVERT(datetime, {{GetObjectsWithAccount.data.EventDate[i]}}))=0

Hi @jclutterbuck - The SQL resource in Retool is a tad different than traditional SQL on a DB, Retool uses sql · agershun/alasql Wiki · GitHub which doesnt appear to support DATEDIFF at this time.

However, you can use the transformer and use the momentjs library to add the DateDifference "field" Moment.js | Docs

Hey @teamrappid, I've been banging my head on this one for a while.

Could you provide an example of how you'd use the transformer to add the date difference field?

Hi @scullen - Here is an example, the key is using moment.diff() the docs for the exact params can be found here: Moment.js | Docs

1 Like

Hey @teamrappid - awesome thanks!