I am trying to generate a report which fetches quarterly report i.e. based on startDate and endDate. How to calculate startDate and endDate of any quarter if I have quarter name as Q1 and year as parameters in XQuery or Marklogic.
Example: if I have Quarter=q1 and Year=2018 as parameters, then I need to get startDate as 01-01-2018 and endDate as 31-03-2018
You could use
functx:last-day-of-month()
and other standard date functions to construct the start and end date for the given year and quarter.The example code below will return a sequence of
xs:date
objects with the first being the start date, and the second the end date.You could enhance that to instead construct and return a
cts:and-query()
withcts:element-range-query
: