Xpath for Previous Calendar Month

0
Hi I need some help in filtering data based on a created_date for previous calendar month.  Thanks
asked
2 answers
0

See my edit below. Do not use this method.

To do this purely in XPath (e.g. in a data grid), you can use:

 

[Date >= '[%BeginOfCurrentMonthUTC%] - [%MonthLength%]']
[Date <= '[%EndOfCurrentMonthUTC%] - [%MonthLength%]']

 

Updated my test case

I set my system time to 06-06-2018 (a month which has 30 days). This results in the following:

From this test case, it's clear that Stefan is correct and that this XPath should not be used. It's strange that this token can be used though: the result is unintuitive and it's missing from the documentation.

 

answered
3

Depends a bit on your specific situation but you could do the following:

1. Create a Variable Date Time with the begin of this month minus 1, like this  : addMonths([%BeginOfCurrentMonth%], -1)

 

2. Do the database retrieve with Xpath and compare the months with the month from date time function:

[month-from-dateTime($MonthVariable) =  month-from-dateTime(createdDate)]

answered