Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

week start/end and number by the date

epipkoFeb 9 2021

Oracle 19c on Windows.
I have a query that returns dates of cargo arrival. I need to determine what week of the month this date falls into. Also, how do I find a start/end date for that week?
This can be used as a test
select to_date('3/3/2021','mm/dd/yyyy') port_date, 100 cargo_wt from dual
union all
select to_date('3/5/2021','mm/dd/yyyy') port_date, 98 cargo_wt from dual
union all
select to_date('3/14/2021','mm/dd/yyyy') port_date, 33 cargo_wt from dual

I tried to use to_date(port_date,'W') to determine the week number. It shows that 3/14 falls into week 2. Is this an expected behaviour? Is it Monday to Sunday? If this is correct, then how to determine the start/end dates of the week?

Comments
Post Details
Added on Feb 9 2021
10 comments
2,555 views