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!

Date of last week thursday

AceNoviceJul 17 2017 — edited Jul 18 2017

Hi All,

I'm working on Informatica solution for increment logic. I need to extract data till last week's Thursday. No matter, when extraction process starts this week, it should have end date as last week's Thursday.

For example,Today is

7/16/2017 (Sunday) - End date should be 07/13/2017

7/17/2017 (Monday) - End date should be 07/13/2017

7/18/2017 (Tuesday) - End date should be 07/13/2017

7/19/2017 (Wednesday) - End date should be 07/13/2017

7/20/2017 (Thursday) - End date should be 07/13/2017

7/21/2017 (Friday) - End date should be 07/13/2017

7/22/2017 (Saturday) - End date should be 07/13/2017

I did some google,and took help of Oracle manual and came up with below SQL. It works fine till Wednesday (07/19/2017), but when current date becomes Thursday (07/20/2017), it returns 07/20/2017 instead of 07/13/2017.

SELECT trunc(SYS_DATE + 2, 'd') -3 from (

SELECT SYSDATE + 4 from dual )

Can someone please help me to find what I missed here....

This post has been answered by BrunoVroman on Jul 17 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 15 2017
Added on Jul 17 2017
5 comments
1,236 views