Home > FAQ > Data Manipulation > Date Rounding in Expressions > Beginning of the next ... examples > Beginning of the next semi-month

Beginning of the next semi-month

This is the recommended expression for rounding dates to the beginning of the next semi-month:

BOSM1_DT:= #IF 14 >= #DAY A_DT
           #THEN 14 + #BEGMTH A_DT
           #ELSE #NEXTBEGMTH A_DT
           #ENDIF &

A_DT may be either a single date (e.g., 7/16/2015, DOH, #DODEC) or an array of dates (e.g., #DATE). 

If the date is before the middle of the month (14 >= #DAY A_DT), then we we want to round the date to the middle of the current month (14 + #BEGMTH A_DT). Otherwise, round the date to the beginning of the next month (#NEXTBEGMTH A_DT).

If you want the 16th to be the beginning of the semi-month, then change 14 to 15 in the above expression.