{"id":85,"date":"2008-08-20T15:59:09","date_gmt":"2008-08-20T19:59:09","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2008\/08\/20\/get-dates-corresponding-to-calendar-week-days-in-oracle\/"},"modified":"2008-08-20T15:59:09","modified_gmt":"2008-08-20T19:59:09","slug":"get-dates-corresponding-to-calendar-week-days-in-oracle","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2008\/08\/20\/get-dates-corresponding-to-calendar-week-days-in-oracle\/","title":{"rendered":"Get dates corresponding to calendar week days in Oracle"},"content":{"rendered":"<p>To do so, we will make use of Oracle&#8217;s next_day() function.  The sample code is as follows:<\/p>\n<pre class=\"code\">select next_day(sysdate-14,'SUNDAY') as week_start, next_day(sysdate-7,'SATURDAY') as week_end from dual;<\/pre>\n<p>Assuming the current date is 20 Aug 2008, the above code will return 10 Aug 2008 and 16 Aug 2008, reflecting that the previous calendar week is between Sunday the 10th and Saturday the 16th.  Thus, your query to get records inserted in the previous calendar week may look something like the following.<\/p>\n<pre class=\"code\">\nselect record_id, record_stuff, entry_date\nfrom bunch_of_records\nwhere entry_date between \n\tnext_day(sysdate-14,'SUNDAY') and \n\tnext_day(sysdate-7,'SATURDAY');\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The code demonstrated in this article will allow you to get the dates reflecting calendar week days.  This may be useful, for instance, if you are running a query to get records inserted between the previous calendar week.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-oracle"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=85"}],"version-history":[{"count":0,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/85\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}