How to achieve second Sunday of March in Every year
0
Hello, I am trying to validate the Daylight savings value for the given date. For this, I am trying to get the second Sunday of March and the first Sunday of November in each year. and then going to check whether the given current date is between these two dates. I was able to get the 1st day of March, but not sure how to achieve the Second Sunday of March in the year. Can anyone please help me to get this? or suggest any other solution to validate Daylight Saving for the given date? Thanks in Advance!!
asked
Valli Maruthi Bathala
1 answers
2
Hi Valli,
In order to get the second Sunday of march I would do the following (considering you know the first day of march.
Create a variable firstDayMarch as integer
Set the variable to an integer using: parseInteger(formatDateTime($Date, 'u'))
Create an integer variable daysToAdd
Change daysToAdd to 14 – firstDayMarch. For example: if the first day of March is a monday (1) than sunday is 14 – 1 = 13 days away. If the first day is a sunday, the second sunday is 14-7 = 7 days away.
The second sunday of march is now: addDays($Date, daysToAdd)