Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle : Query to get the Last Friday of the week if I give any date

If I give a date let's say '13-Mar-2019' my query needs to retrieve the value '15-Mar-2019'. Which is the last Friday of the week.

like image 915
Anji007 Avatar asked Nov 26 '25 02:11

Anji007


1 Answers

Trancate the date to the ISO week, which gets you the week's Monday (as an ISO week starts with Monday). Then add four days:

select trunc(date '2019-03-13', 'iw') + 4 from dual;
like image 188
Thorsten Kettner Avatar answered Nov 27 '25 16:11

Thorsten Kettner