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

Beginning of the current semi-month

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

BOM_DT:= #BEGMTH A_DT & ; find the beginning of the current month
BOSM_DT:= BOM_DT + [14 * {14 < (A_DT - BOM_DT)}] &
; add 14 days to the beginning of the month if the date is after the 14th

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

We start by finding the beginning of the month using #BEGMTH, and then if the original day of the month is after the 14th (i.e., 15th day of the month or later), we add 14 days to the beginning of the month to get the beginning of the the semi-month (i.e., the 15th of the month).

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