Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding day of the week in oracle

Tags:

sql

oracle

to_char(sysdate,'Day') returns the current day of the week. What I want is to get the date of the most recent "sunday" that passed. Of course we can go for a complex query to get it done. But is there any simple way I'm not aware of?

like image 735
venkatKA Avatar asked Feb 18 '23 22:02

venkatKA


1 Answers

You can do it with

SELECT NEXT_DAY(SYSDATE-8, 'SUN') FROM DUAL;

here

SYSDATE-8

returns the day before 8 days &

NEXT_DAY(mydate, 'SUN') 

returns the next sunday to it

like image 156
Rohit Chaudhari Avatar answered Feb 25 '23 12:02

Rohit Chaudhari