XPath Date + 1

0
Hi i am looking to select where todays date is greater than the daty after the end date. Currently i am using: [EndDate<'[%CurrentDateTime%]'] I tried to use this to add 1 day: [addDays(dateTime(EndDate), 1)<'[%CurrentDateTime%]'] But i get the error unknown fuction addDays. What am i doing wrong?
asked
3 answers
1

Hi Michael,

Did you had a look at this forum post https://forum.mendix.com/link/questions/100641

or try 

[EndDate < '[%CurrentDateTime%] + 1 * [%DayLength%]']

Hope this helps!

answered
0

Hi Michael,

You're looking for the token [%DayLength%].

Please see examples at the bottom of https://docs.mendix.com/refguide/xpath-keywords-and-system-variables

I think this would work:

[EndDate < ('[%CurrentDateTime%]' + 1* [%DayLength%])] 

 

But you could also use [EndDate < '[%EndOfCurrentDay%]'

answered
0

Michael,

Unfortunately, you can’t add days to EndDate (since its not a system variable).  However, I think you can meet your requirement by doing the following:

[EndDate < ('[%CurrentDateTime%]' - 1* [%DayLength%])]

I think subtracting 1 day from CurrentDateTime is equivalent to adding 1 day to EndDate.  

One other thing to be aware of:  CurrentDateTime (and EndDate) contain datetime values.  So the value of EndDate might be July 7 @ 10:30AM even though you may only see the July 7 when its displayed on a page.  This may lead to unexpected results if you don’t take it into account.

Hope that helps,

Mike

answered