COMPUTING BETWEEN DATES
Hello,
I would like to compute the number of years between two dates. Any can help ? I also need to compute a delay to add to a starting date. Example : starting date + 3 years...
Best regards
5 replies
-
–––
(year('Date2') - year('Date1')) - if month('Date2') < month('Date1') or (month('Date2') = month('Date1') and day('Date2') < day('Date1')) then 1 else 0 end
–––
Birger
-
Birger,
Thanks for your prompt reply.
In Belgium, for a lease contract, we have to end the contract the day before the year. For example, 1/1/2019 to 31/12/2019. Even though your code is correct on the logical point of view, on the juridical point of view is not correct. We need to change the "then 1 else 0" by " then 0 else -1".
Thanks a lot for your help ! Have a nice day...
-
Hi Raphael,
Please try it with this one:
(year('Date2') - year('Date1')) - if month('Date2') < month('Date1') or (month('Date2') = month('Date1') and day('Date2') < day('Date1') - 1) then 1 else 0 end
Best, Jörg
-
Jörg,
Thanks for the message but your answer is the same as the Birger's answer... ;-)
-
Hi Raphael,
No, the last part is different ;)
There is a -1 in the brackets before the last then
Best, Jörg
Content aside
- 5 yrs agoLast active
- 5Replies
- 1348Views