Forum Discussion

vaidyarm's avatar
vaidyarm
Contributor
4 years ago

How to divide dates in to custom quarters

I have a special quarter division requirement where I have to allot data to different quarters based on the dates they belong, for this I need to get the first Monday of each month, tried the below logic to get it but not working for the Monday part.

Date.parse(‘2022-02-03’).getDay() == 1 ? Date.parse(‘2022-02-03’) : Date.parse(‘2022-02-03’).withDayOfWeek(1)

3 Replies

  • Do you have a predefined set of dates, or you want to generate all quarters within SnapLogic and then get the first Monday of each month ?

    • vaidyarm's avatar
      vaidyarm
      Contributor

      Sorry, I guess I read it a bit incorrect, it’s more complicated than I thought it would be,

      Details:

      • Last quarter always end on November’s last Friday (i.e. 4th quarter whatever be the date on that Friday)
      • Hence next year’s 1st quarter will start from Saturday (whether it be from the month of November or December).
      • each quarter is of 91 days, this more clear from the below image