Days per week

Days per week

  

How to get 1 week starting on monday on advanced SQL? 

Ex:

first         last

04     -     10 Sept


11    -       17 Sept


18    -       24 Sept


25    -       01 Oct


Anyone does this one already? Thanks

Hi Jay,

Could you explain more about what you trying to do?



Hi Jay, 


I don't know if I understood the question, but in Oracle, given any date, you can get the corresponding week (monday to sunday) like this: 

select TRUNC(to_date('01-09-2017','dd-mm-yyyy'), 'iw') AS iso_week_start_date,
       TRUNC(to_date('01-09-2017','dd-mm-yyyy'), 'iw') + 7 - 1/86400 AS iso_week_end_date
from dual


Just replace '01-09-2017' for any date you need. Did it help?

Regards, 


  

Hi,

This query can be easily change to get all the weeks of a year:

https://blog.sqlauthority.com/2009/12/29/sql-server-get-date-of-all-weekdays-or-weekends-of-the-year/

Regards,

Marcelo