Calculate Last Business Day of Previous Month

Database
Enthusiast

Calculate Last Business Day of Previous Month

I use the below select query to extract the last date of all completed months (current year to date) :

SELECT CALENDAR_DATE-1 AS CALENDAR_DT FROM SYS_CALENDAR.CALENDAR WHERE DAY_OF_MONTH = 1
AND MONTH_OF_CALENDAR - 1 BETWEEN MONTH_OF_CALENDAR(ADD_MONTHS((DATE - EXTRACT(DAY FROM DATE)+1), -(EXTRACT (MONTH FROM DATE))+1)) AND MONTH_OF_CALENDAR((DATE - EXTRACT(DAY FROM DATE)))

I would need a script which take in a date as a prompt and returns the last business day of the previous month. Can someone help me ??

Tags (1)
2 REPLIES
Junior Contributor

Re: Calculate Last Business Day of Previous Month

Hi Sarang,

what's your definition of business day?

Enthusiast

Re: Calculate Last Business Day of Previous Month

Hi Dieter,

Business Day is a working day between Mon to Fri in a week, except for weekends and holidays in the year (holiday dates are stored in a separate holiday table)