Forum Discussion
PrashantMaheshw
3 years agoQrew Captain
PAUL holiday formula query would be greatly appreciated ! Please do post
------------------------------
Prashant Maheshwari
------------------------------
------------------------------
Prashant Maheshwari
------------------------------
PaulPeterson1
3 years agoQrew Assistant Captain
This is how I addressed the problem. There may be something more elegant, but this is tested and does work.
I put the holiday dates in a Holiday table. I also added a formula text field for Holiday Observed:
I put the holiday dates in a Holiday table. I also added a formula text field for Holiday Observed:
ToText(ToWeekdayN([Holiday]))
For the Third Work Day I used:
var text tableID = "tid";
var text query = "{hoFID.GTE." & [Test Date] & "}";
var TextList dates = GetFieldValues(GetRecords($query, $tableID), hoFID);
var bool isHoliday = Contains($dates, ToText(FirstDayOfMonth([Test Date]))) or
Contains($dates, ToText(WeekdayAdd(ToWeekdayN(FirstDayOfMonth([Test Date])), 1))) or
Contains($dates, ToText(WeekdayAdd(ToWeekdayN(FirstDayOfMonth([Test Date])), 1)));
var number dayOffset = If($isHoliday, 3, 2);
WeekdayAdd(ToWeekdayN(FirstDayOfMonth([Test Date])), $dayOffset)
where tid is the table ID for the Holidays table and hoFID is the field IF for Holiday Observed.
The formula query will return a list of holidays that are on or after the Test Date field. The isHoliday variable will check to see if the holiday observed date is in the first three working days of the month. The dayOffset will return 3 if isHoliday is true and 2 if it is false.
I hope this helps. Let me know if you have any questions.
------------------------------
Paul Peterson
------------------------------
- PaulPeterson13 years agoQrew Assistant CaptainAfter posting, I had a thought about holidays like Christmas Eve, Christmas Day and New Years Eve, New Years Day and made the following modifications:
var number holidays = If(Contains($dates, ToText(FirstDayOfMonth([Test Date]))), 1) + If(Contains($dates, ToText(WeekdayAdd(ToWeekdayN(FirstDayOfMonth([Test Date])), 1))), 1) + If(Contains($dates, ToText(WeekdayAdd(ToWeekdayN(FirstDayOfMonth([Test Date])), 2))), 1) + If(Contains($dates, ToText(WeekdayAdd(ToWeekdayN(FirstDayOfMonth([Test Date])), 2))) >0 and Contains($dates, ToText(WeekdayAdd(ToWeekdayN(FirstDayOfMonth([Test Date])), 3))), 1); var number dayOffset = 2 + $holidays;
------------------------------
Paul Peterson
------------------------------- PrashantMaheshw3 years agoQrew CaptainThanks Paul !
------------------------------
Prashant Maheshwari
------------------------------