How to find Nth weekday from current date? [message #631073] |
Thu, 08 January 2015 16:42 |
|
Hi,
I have a requirement to find 5th business day from current date. For example, If current date is 01/08/2015 Thursday then my output would be 01/01/2015 Thursday (5th business day from sysdate). Please help.
|
|
|
|
|
|
Re: How to find Nth weekday from current date? [message #631079 is a reply to message #631076] |
Thu, 08 January 2015 21:56 |
|
Sorry Blackswan for not providing exact date format which I have used as example. I have used mm/dd/yyyy as format in the example. My requirement was only to cover weekdays, I was curious to know if that consider holiday. Sorry for the stupid question. Your answer is accurate and I have changed as given below to calculate 5th business day in backwards.
|
|
|
Re: How to find Nth weekday from current date? [message #631101 is a reply to message #631079] |
Fri, 09 January 2015 04:18 |
jimit_shaili
Messages: 237 Registered: June 2006 Location: India, Ahmedabad
|
Senior Member |
|
|
Dear Oracle_Walker
This may solve your query.
Note : Saturday and Sunday are considered as holidays. (Non business days)
select max(dt) as business_day_5th from
(
select dt from
(
select trunc (sysdate, 'dd') + level - 1 as dt,to_char(trunc(sysdate, 'dd') + level - 1,'d') wd from dual connect by level < = 8
)
where wd not in(1,7)
)
/
Regards
Jimit
|
|
|
|
|
|