Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Static date in Datetime_diff function

Topic Labels: Formulas
Solved
Jump to Solution
2523 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Travis_Monczko1
4 - Data Explorer
4 - Data Explorer

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

1 Solution

Accepted Solutions
Julian_Kirkness
10 - Mercury
10 - Mercury

You can use the following formula:

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

Hope this helps!

See Solution in Thread

3 Replies 3
Julian_Kirkness
10 - Mercury
10 - Mercury

You can use the following formula:

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

Hope this helps!

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

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')