Find the first Friday in a month
The date operator #DAYOFWEEK indicates the day of week: 1 = Monday, 2= Tuesday, 3 = Wednesday, 4= Thursday, 5 = Friday, 6 = Saturday, and 7 = Sunday. This technique works because every date (in an expression) is the number of days since 1/1/1900.
; A_DT is a single date or an array of date(s) that you need to
; adjust (e.g., DOB field or #DATE in a transformation expression)
BegMth_DT:= -1 #MONTHROUND A_DT & ; round to 1st of month
DaysToFri:= 5 - #DAYOFWEEK BegMth_DT & ; days from FRI
; M T W T F S S Day of week
; 1 2 3 4 5 6 7 #DAYOFWEEK
; 4 3 2 1 0 -1 -2 days to Friday
; if the first day of the month is Monday thru Friday, then
; BegMth + DaysToFri is a Friday, and it’s the first Firday
; of the current month. But if the first day of the month is
all> ; Saturday or Sunday, then BegMth + DaysToFri is a Friday,
; but it’s the last Friday of the previous month! So, if the
; first day of the month is Saturday or Sunday, then
; BegMth + DaysToFri + 7 is the first Friday of the current month
BegMth_DT + DaysToFri + (7 * (DaysToFri <0))