Static date in Datetime_diff function

#1

Hi there

I’d like to use the datetime_diff() function to compare a date in the {Date} column of each record to a fixed date: 29 March 2019.

I can’t seem to figure out the syntax to insert that fixed date into the formula:

datetime_diff({Date}, [what syntax to make 2019-03-29 a datetime?], ‘days’}

Thanks
Travis

0 Likes

#2

You can use the following formula:

DATETIME_DIFF({From Date}, DATETIME_PARSE(“2019-03-29”), ‘days’)

Hope this helps!

2 Likes

#3

Thanks Julian, yes that has done it. Turns out I had been missing the double quotes within the DATETIME_PARSE() function. Cheers!

0 Likes

#4

For anyone reading over @Travis_Monczko1’s shoulder, note that if your embedded datetime is potentially ambiguous — for instance, is '04-12-2019' April 12th or December 4th? — you’ll need to add a format specifier to the DATETIME_PARSE() function. For instance:

DATETIME_DIFF({From Date},DATETIME_PARSE('04-12-2019','MM-DD-YYYY'),'days')

0 Likes