|
|
|
|
Re: Date for Sunday prior to given date [message #673993 is a reply to message #673992] |
Thu, 20 December 2018 13:56 |
Solomon Yakobson
Messages: 3269 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
Michel's solution will give you Sunday before or equal to a given date, not before given date:
SQL> select next_day(date '2018-12-23','Sunday')-7 from dual;
NEXT_DAY(
---------
23-DEC-18
SQL>
If you want Sunday before a given date and regardless of client NLS settings use
trunc(given_date,'iw') - 1
For example:
SQL> select trunc(date '2018-12-20','iw') - 1 from dual;
TRUNC(DAT
---------
16-DEC-18
SQL> select trunc(date '2018-12-23','iw') - 1 from dual;
TRUNC(DAT
---------
16-DEC-18
SQL>
SY.
|
|
|