All Forums Database
Saarang84 16 posts Joined 08/14
21 Oct 2014
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 ??

Sarang

dnoeth 4628 posts Joined 11/04
21 Oct 2014

Hi Sarang,
what's your definition of business day?

Dieter

Saarang84 16 posts Joined 08/14
22 Oct 2014

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)

Sarang

You must sign in to leave a comment.