Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Do we have any function 'Previous_day' in oracle like 'next_day'??

bhaskar_subbiahDec 14 2016 — edited Dec 15 2016

Hi Experts,

I have one request where i need to get previous wednesday. In oracle we have a function 'NEXT_DAY' function to get next occurrence of a day.

SELECT TO_CHAR(NEXT_DAY(SYSDATE,'WEDNESDAY'),'MM/DD/YYYY') from DUAL;   --This query give output as 12/21/2016.

similar to next_day function do we have any function in oracle to get previous day? to get previous 'Wednesday' ? i tried another and below query worked.

select trunc((next_day(last_day(sysdate),'wednesday'))-28) from dual;  -- (If this has any fault kindly correct me)

But do we have any other alternate way to get previous Wednesday or any day as we wish?

Do lemme know for any further info.

Regards

Bhaskar.S

This post has been answered by Chris Hunt on Dec 14 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2017
Added on Dec 14 2016
13 comments
2,754 views