{"id":27,"date":"2006-02-10T06:34:48","date_gmt":"2006-02-10T05:34:48","guid":{"rendered":"http:\/\/bar-solutions.com\/wordpress\/?p=27"},"modified":"2006-02-10T07:07:04","modified_gmt":"2006-02-10T06:07:04","slug":"handy-date-functions","status":"publish","type":"post","link":"https:\/\/blog.bar-solutions.com\/?p=27","title":{"rendered":"Handy date functions&#8230;"},"content":{"rendered":"<p>I came across the need to define the first day of next month based on the current systemdate. I can do this using the following code:<\/p>\n<p>add_months(to_date(&#8217;01&#8217;||to_char(sysdate,&#8217;MMYYYY&#8217;),&#8217;DDMMYYYY&#8217;),1)<\/p>\n<p>But the I remembered that there was a post on the <a title=\"Posting on oracledeveloper.nl (dutch)\" href=\"http:\/\/www.oracledeveloper.nl\/index2.cfm?forum=1&#038;thread=60&#038;message=147\" target=\"_blank\">oracledeveloper.nl<\/a> forum with similar date functions.<\/p>\n<p>First day of the week: select trunc(sysdate,&#8217;IW&#8217;) the_date\u00a0from dual;<br \/>\nFirst day of the month: select trunc(sysdate,&#8217;MM&#8217;) the_date from dual;<br \/>\nFirst day of the year: select trunc(sysdate,&#8217;IY&#8217;) the_date from dual;<\/p>\n<p>Using this information the above code could be rewritten to:<\/p>\n<p>add_months(trunc(SYSDATE, &#8216;MM&#8217;),1)<\/p>\n<p>A lot shorter and I think also better, because you don&#8217;t have to do with date masks etc.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I came across the need to define the first day of next month based on the current systemdate. I can do this using the following code: add_months(to_date(&#8217;01&#8217;||to_char(sysdate,&#8217;MMYYYY&#8217;),&#8217;DDMMYYYY&#8217;),1) But the I remembered that there was a post on the oracledeveloper.nl forum with similar date functions. First day of the week: select trunc(sysdate,&#8217;IW&#8217;) the_date\u00a0from dual; First day [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5,9],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-oracle","category-plsql","category-sql"],"_links":{"self":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=27"}],"version-history":[{"count":0,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bar-solutions.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}