Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date of Monday of a given week, independent of NLS

Tags:

oracle

I have an input date (say sysdate) and I want to get the date of the previous Monday. I tried

select trunc(sysdate, 'D') from dual;

but it is NLS dependent. Also I don't want to go around with checking the result by name because it may vary depending on the language of the country that my code will run on.

like image 671
Alpaslan Avatar asked Mar 24 '23 03:03

Alpaslan


1 Answers

Try to use ISO weeks

SELECT TRUNC(SYSDATE, 'IW') - 7 previous_monday FROM dual

Here is SQLFiddle demo

like image 176
peterm Avatar answered Apr 07 '23 14:04

peterm