Date difference

What is the easiest way to calculate the difference between two dates like DATEDIFF() in Tableau?
Or
How can I check if a date is in a range of two dates?

As there is no build in function for that I need to implement my own logic like:
if(year([Year1]) - year([year2] > 0 AND month([month1]) - month([month2]) > 0 AND day([day1]) - day([day2]), “TRUE”, “FALSE”)
^ this needs a lot of effort and is not easy to maintain…

edit: I just noticed is that simple subtraction of two dates works!

That's correct. Similarly to Excel, in EasyMorph dates are just formatted numbers. So the difference between two dates is simply one minus the other.

1 Like

brilliant, however I couldn’t find anything with the search function that would have told me that, is it missing in the documentation?

Good point – thanks for bringing it up!

This is mentioned in our tutorial on expressions: http://easymorph.com/learn/expressions.html, but we clearly need to explain it in more details in our web-help.

thank you for linking me!