Arctus Blog: Oracle: Two useful date functions http://blog.arctus.co.uk/articles/2007/05/01/oracle-two-useful-date-functions en-us 40 Oracle: Two useful date functions <p>Here are two useful functions for processing dates. They take a valid date, e.g. &#8220;01/05/2007 10:22&#8221;, and either set the time to midnight (the start of the day) or 23:59 (the end of the day).</p> <p>This allows us to use the dates to calculate to the whole day, rather than to a fraction, and to perform basic date management in cases where the time is not an important factor.</p> <p>The functions:</p> <div class="CodeRay"> <div class="code"><pre>function Date_ToStartOfDay (d date) return date as return_value date; begin return_value := to_date(to_char(d, 'DD-MM-YYYY'), 'DD-MM-YYYY'); return return_value; end; function Date_ToEndOfDay (d date) return date as return_value date; begin return_value := to_date(to_char(d, 'DD-MM-YYYY') || ' 23:59', 'DD-MM-YYYY HH24:MI'); return return_value; end;</pre></div> </div> Tue, 01 May 2007 05:21:00 -0400 urn:uuid:c6069dd3-7645-4243-80de-43440e5025ab adrian@arctus.co.uk (Adrian O'Connor) http://blog.arctus.co.uk/articles/2007/05/01/oracle-two-useful-date-functions Oracle