About EasyMorph Tutorials & Examples Web-help

Calculation on Date expression

Thanks for your help in advance.

Someone please help me how to plus or minus on date function.
I just found out this.

With following expression,
format(now()-60, ‘yyyyMMdd’)

Now is 2020-01-03, it subtract from 2020-01-03 to 60 days
The result shows 2019-11-4.

Here is a question.
How can I subtract hour from now() expression?
The following expression is what i used, but it won’t work I intended.
I want to subtract 2 hours from current time.

  • format(now()-2, ‘HH:mm’)

I will apply other cases based on your answer.

Thank you.

For dates 1 is a whole day, i.e. 24 hours. Therefore, if you want to subtract 2 hours you have to subtract not 2 (which is 2 days), but 2/24. The expression should be:

format(now()-2/24, ‘HH:mm’)

Alternatively, you can use function addhours().

Wonderful! Thanks for your help!

To learn more about EasyMorph visit easymorph.com.