Search code examples
sqloracle-databasetimestamporacle9i

In oracle SQL, how would you obtain the timestamp representing the start of the week?


I'm using an Oracle 9i database and want to obtain, within a function, the timestamp representing the start of the week, i.e. The most recent monday, at 00:00:00.

I am aware that the timestamp representing the start of the current day is TO_TIMESTAMP(SYSDATE).


Solution

  • You can use the function next_day to get that:

    SQL> select next_day(sysdate-7, 'MONDAY') FROM DUAL;
    
    NEXT_DAY
    ---------
    29-APR-13