
Announcements
I am trying to get the date for second Sunday of march month
// Set the year and month for which you want the second Sunday
Set(gloYear, 2024);
Set(gloMonth, 3); // Example: March 2024
// Calculate the first day of the month
Set(gloFirstDayOfMonth, DateValue(gloYear & "-" & gloMonth & "-1"));
// Determine the day of the week for the first day of the month (0=Sunday, 1=Monday, ..., 6=Saturday)
Set(gloFirstDayOfWeek, Weekday(gloFirstDayOfMonth) - 1);
// Calculate the second Sunday
// If the first day is Sunday, the second Sunday will be 7 plus the first day of month, otherwise calculate the second Sunday by adding the number of days needed
Set(gloSecondSunday,
If(
gloFirstDayOfWeek = 0,
DateAdd(gloFirstDayOfMonth, 7, TimeUnit.Days),
DateAdd(gloFirstDayOfMonth, 14 - gloFirstDayOfWeek, TimeUnit.Days)
)
);
Set(
varmarchsecondsunday,
gloSecondSunday
)