<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
	xmlns:media="http://search.yahoo.com/mrss/"
>

<channel>
	<title>Dave's Adventures in Business Intelligence &#187; Dynamic Dates</title>
	<atom:link href="http://www.dagira.com/category/design/dynamic-dates/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dagira.com</link>
	<description>...you are in a twisty maze of passageways, all different...</description>
	<lastBuildDate>Wed, 01 Feb 2012 17:26:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<!-- podcast_generator="podPress/8.8" -->
		<copyright>&#xA9; </copyright>
		<managingEditor>blogmaster@dagira.com ()</managingEditor>
		<webMaster>blogmaster@dagira.com()</webMaster>
		<category></category>
		<ttl>1440</ttl>
		<itunes:keywords></itunes:keywords>
		<itunes:subtitle></itunes:subtitle>
		<itunes:summary>...you are in a twisty maze of passageways, all different...</itunes:summary>
		<itunes:author></itunes:author>
		<itunes:category text="Society &amp; Culture"/>
		<itunes:owner>
			<itunes:name></itunes:name>
			<itunes:email>blogmaster@dagira.com</itunes:email>
		</itunes:owner>
		<itunes:block>No</itunes:block>
		<itunes:explicit>no</itunes:explicit>
		<itunes:image href="http://www.dagira.com/wp-content/plugins/podpress/images/powered_by_podpress_large.jpg" />
		<image>
			<url>http://www.dagira.com/wp-content/plugins/podpress/images/powered_by_podpress.jpg</url>
			<title>Dave's Adventures in Business Intelligence</title>
			<link>http://www.dagira.com</link>
			<width>144</width>
			<height>144</height>
		</image>
		<item>
		<title>Dynamic Dates Part V: More Databases</title>
		<link>http://www.dagira.com/2008/09/23/dynamic-dates-part-v-more-databases/</link>
		<comments>http://www.dagira.com/2008/09/23/dynamic-dates-part-v-more-databases/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 12:30:44 +0000</pubDate>
		<dc:creator>Dave Rathbun</dc:creator>
				<category><![CDATA[Dynamic Dates]]></category>
		<category><![CDATA[Universe Design]]></category>

		<guid isPermaLink="false">http://www.dagira.com/?p=25</guid>
		<description><![CDATA[Some time back I posted a series of articles describing how to create &#8220;dynamic date&#8221; objects based off of the current system date. For examples I used the Oracle database. This post simply contains a collection of links that I have found to references for date/time functions for other databases. I hope it will be [...]]]></description>
			<content:encoded><![CDATA[<p>Some time back I posted a <a href="http://www.dagira.com/category/design/dynamic-dates/">series of articles</a> describing how to create &#8220;dynamic date&#8221; objects based off of the current system date. For examples I used the Oracle database. This post simply contains a collection of links that I have found to references for date/time functions for other databases. I hope it will be useful.</p>
<h3>Related Links</h3>
<ul>
<li><a href="http://www.ibm.com/developerworks/db2/library/techarticle/0211yip/0211yip3.html">DB2 Date Functions</a></li>
<li><a href="http://www.inquiry.com/techtips/info_pro/10min/10min1000/10min1000-2.asp">Informix Date Manipulation</a></li>
<li><a href="http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html">MySQL Date and Time Functions</a></li>
<li><a href="http://www.psoug.org/reference/date_func.html">Oracle Date Functions</a></li>
<li><a href="http://www.teradataforum.com/l030515a.htm">Dates and Times in Teradata</a></li>
<li><a href="http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/">SQL Server Datetime functions</a></li>
</ul>
<p><span class="disclaimer">External links are provided without endorsement and may become inactive at any time. These links were functioning properly at the time this blog post was published but dagira.com has no guarantee that they will continue to be available.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dagira.com/2008/09/23/dynamic-dates-part-v-more-databases/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dynamic Dates Part IV: Yearly Date Ranges</title>
		<link>http://www.dagira.com/2007/09/25/dynamic-dates-part-iv-yearly-date-ranges/</link>
		<comments>http://www.dagira.com/2007/09/25/dynamic-dates-part-iv-yearly-date-ranges/#comments</comments>
		<pubDate>Tue, 25 Sep 2007 21:18:40 +0000</pubDate>
		<dc:creator>Dave Rathbun</dc:creator>
				<category><![CDATA[Dynamic Dates]]></category>
		<category><![CDATA[Universe Design]]></category>

		<guid isPermaLink="false">http://www.dagira.com/2007/09/25/dynamic-dates-part-iv-yearly-date-ranges/</guid>
		<description><![CDATA[Last Time On This Subject&#8230;
This is the fourth in my series about dynamic date objects. The first three included objects for daily, weekly, and then monthly ranges. I am going to complete my collection of Oracle-based dynamic date objects by providing yearly objects in this post.

Current Year
In the monthly post I showed how the Oracle [...]]]></description>
			<content:encoded><![CDATA[<h3>Last Time On This Subject&#8230;</h3>
<p>This is the fourth in my series about dynamic date objects. The first three included objects for daily, weekly, and then monthly ranges. I am going to complete my collection of Oracle-based dynamic date objects by providing yearly objects in this post.<br />
<span id="more-27"></span></p>
<h3>Current Year</h3>
<p>In the monthly post I showed how the Oracle trunc() function can be used to truncate (remove) everything except for the year and month. Here&#8217;s how to apply the same technique and get the first day of the year:</p>
<p><code>trunc(sysdate,'YYYY')</code></p>
<p>The formula shown above will &#8220;round off&#8221; the date to the year. Since the return value for this function has to be a date, Oracle returns the year + first month month + first day of the year. Short and simple. I have seen other formulas that convert a date to a string, extract the year with a substring operation, and then combine it back with &#8216;01&#8242; for the day and &#8216;01&#8242; for the month and then convert it back to a date. My advice? Use the trunc() function. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Readers that have followed this complete series will not be surprised with where I go to get the end of the current year. I could get the year from the current date (using string functions as outlined in the prior paragraph) and add in December and 31 for the day. Instead I will use this:</p>
<p><code>last_day(add_months(trunc(sysdate,'YYYY'), 11))</code></p>
<p>The advantage of this formula is that everything is based on date math. When I convert a date to character data and then use character functions there is a chance that the result value won&#8217;t be a valid date unless I do a lot of error checking. This way is fairly simple.</p>
<p>Why do I apply the trunc() function first? I do that to get to a constant starting point. Get to a known point and the offset (11 months) is always the same.</p>
<h3>Last Year</h3>
<p>As before I will be setting up objects for the prior year as well. This time instead of using the @Select() function I will do something slightly different. I will give you lots of options. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<table class="blogtable">
<tr>
<th>Date</th>
<th>Formula</th>
</tr>
<tr class="alt">
<td nowrap="nowrap">Start of Last Year V1</td>
<td class="code">trunc(trunc(sysdate,&#8217;YYYY&#8217;)-1, &#8216;YYYY&#8217;)
</td>
</tr>
<tr>
<td>Start of Last Year V2</td>
<td class="code">add_months(trunc(sysdate,&#8217;YYYY&#8217;), -12)</td>
</tr>
<tr class="alt">
<td>Start of Last Year V3</td>
<td class="code">trunc(@Select(&#8217;Dynamic Dates\End of Last Year&#8217;), &#8216;YYYY&#8217;)</td>
</tr>
<tr>
<td>End of Last Year</td>
<td class="code">trunc(sysdate,&#8217;YYYY&#8217;)-1
</td>
</tr>
</table>
<h3>What About Fiscal Calendar Years?</h3>
<p>As I said in the prior post on monthly date ranges I would have to use a period calendar table or write custom database functions in order to create fiscal year objects. The standard Oracle database functions work only on a standard calendar. If you have a fiscal calendar and require dynamic yearly dates I strongly suggest that you look at creating a calendar table that supports your requirements. <em>Note: I won&#8217;t be covering that process in this series of posts.</em></p>
<h3>Summary</h3>
<p>Over the past four posts I have built daily, weekly, monthly, and now yearly dynamic date objects. All of the prior posts in this series are conveniently linked below in case you missed one. What&#8217;s next? I realize that not everyone uses Oracle. Some of these formulas can easily be converted to other databases, and some are more challenging. I will try to show some of these same formulas in other databases. I don&#8217;t plan to try to do every date range for every database but will try to cover samples of each.</p>
<p>Remember that these objects are presented <strong>will not parse</strong> in Designer. They don&#8217;t reference a table and therefore will generate an error. As long as these objects are used with at least one &#8220;real&#8221; object on a query they will function perfectly fine.</p>
<h3>Related Posts</h3>
<ul>
<li><a href="http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/">Dynamic Dates Part I: Yesterday and Today</a></li>
<li><a href="http://www.dagira.com/2007/08/30/dynamic-dates-part-ii-weekly-date-ranges/">Dynamic Dates Part II: Weekly Date Ranges</a></li>
<li><a href="http://www.dagira.com/2007/09/12/dynamic-dates-part-iii-monthly-date-ranges//">Dynamic Dates Part III: Monthly Date Ranges</a></li>
<li><a href="http://www.dagira.com/category/design/dynamic-dates/">All posts in this series</a></li>
</ul>
<h3>Oracle functions used in this post</h3>
<ul>
<li>add_months() Returns an offset in months ahead or behind from the date given</li>
<li>last_day() Returns the last day of the month for the date given as an argument</li>
<li>trunc( , &#8216;YYYY) Returns a date value truncated to the first date of the year</li>
</ul>
<h3>Dynamic Dates With Oracle Functions</h3>
<table class="blogtable">
<tr>
<th>Date</th>
<th>Formula</th>
</tr>
<tr class="alt">
<td>Today</td>
<td class="code">trunc(sysdate)</td>
</tr>
<tr>
<td>Yesterday</td>
<td class="code">trunc(sysdate-1)</td>
</tr>
<tr class="alt">
<td>Start of This Week</td>
<td class="code">next_day(trunc(sysdate-7), &#8216;Sunday&#8217;)</td>
</tr>
<tr>
<td>End of This Week</td>
<td class="code">next_day(case to_char(sysdate,&#8217;Day&#8217;) when &#8216;Saturday&#8217; then trunc(sysdate-1) else trunc(sysdate) end, &#8216;Saturday&#8217;)</td>
</tr>
<tr class="alt">
<td>Start of Last Week</td>
<td class="code">@Select(&#8217;Dynamic Dates\Start of This Week&#8217;) &#8211; 7</td>
</tr>
<tr>
<td>End of Last Week</td>
<td class="code">@Select(&#8217;Dynamic Dates\End of This Week&#8217;) &#8211; 7</td>
</tr>
<tr class="alt">
<td>Start of This Month</td>
<td class="code">trunc(sysdate,&#8217;MM&#8217;)</td>
</tr>
<tr>
<td>End of This Month</td>
<td class="code">last_day(trunc(sysdate))</td>
</tr>
<tr class="alt">
<td>Start of Last Month</td>
<td class="code">add_months(@Select(&#8217;Dynamic Dates\Start of This Month&#8217;) , -1)</td>
</tr>
<tr>
<td>End of Last Month</td>
<td class="code">add_months(@Select(&#8217;Dynamic Dates\End of This Month&#8217;) , -1)</td>
</tr>
<tr class="alt">
<td>Start of This Year</td>
<td class="code">trunc(sysdate,&#8217;YYYY&#8217;)</td>
</tr>
<tr>
<td>End of This Year</td>
<td class="code">last_day(add_months(trunc(sysdate,&#8217;YYYY&#8217;),11))</td>
</tr>
<tr class="alt">
<td>Start of Last Year</td>
<td class="code">trunc(trunc(sysdate,&#8217;YYYY&#8217;)-1,&#8217;YYYY&#8217;)</td>
</tr>
<tr>
<td>End of Last Year</td>
<td class="code">trunc(sysdate,&#8217;YYYY&#8217;)-1</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.dagira.com/2007/09/25/dynamic-dates-part-iv-yearly-date-ranges/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Dynamic Dates Part III: Monthly Date Ranges</title>
		<link>http://www.dagira.com/2007/09/12/dynamic-dates-part-iii-monthly-date-ranges/</link>
		<comments>http://www.dagira.com/2007/09/12/dynamic-dates-part-iii-monthly-date-ranges/#comments</comments>
		<pubDate>Wed, 12 Sep 2007 19:57:14 +0000</pubDate>
		<dc:creator>Dave Rathbun</dc:creator>
				<category><![CDATA[Dynamic Dates]]></category>
		<category><![CDATA[Universe Design]]></category>

		<guid isPermaLink="false">http://www.dagira.com/2007/09/12/dynamic-dates-part-iii-monthly-date-ranges/</guid>
		<description><![CDATA[Last Time On This Subject&#8230;
In the first post in this series I introduced the idea of dynamic date objects. The intent was to show how a universe designer can create dynamic date objects that can be used to schedule reports with a condition that changes over time. The first post covered the basic concepts and [...]]]></description>
			<content:encoded><![CDATA[<h3>Last Time On This Subject&#8230;</h3>
<p>In the <a href="http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/">first post</a> in this series I introduced the idea of dynamic date objects. The intent was to show how a universe designer can create dynamic date objects that can be used to schedule reports with a condition that changes over time. The first post covered the basic concepts and included &#8220;Today&#8221; and &#8220;Yesterday&#8221; dynamic date objects. The <a href="http://www.dagira.com/2007/08/30/dynamic-dates-part-ii-weekly-date-ranges/">next post</a> covered weekly ranges. In this post I will further extend the concept to monthly ranges. As with the other posts so far in this series I will be using Oracle functions. </p>
<p><span id="more-26"></span></p>
<h3>Working In the Current Month</h3>
<p>Getting the first date of the current month is really simple with Oracle. There are a number of different ways but here is what I think is the simplest method:</p>
<p><code>trunc(sysdate,'MM')</code></p>
<p>I mentioned before that trunc() is an overloaded function. So far in this series I have used it only to remove the time portion of a date/time value. By adding an additional argument I can remove more than the time element from the date. The formula shown above will &#8220;round off&#8221; the date to the month and year. Since the return value for this function has to be a date, and every date must have a day value, Oracle returns the year + month + the first day of the month. How convenient. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The end of the current month is harder, if only because months have a different number of days. Personally, I use the knuckle trick to remember which months have 30 versus 31 days. Since Oracle doesn&#8217;t have hands I need a different approach. I could use a case statement to check which month I am in and determine the number of days in the month using something like this:</p>
<p><code>case to_char(sysdate,'MON')<br />
when 'JAN' then 31<br />
when 'FEB' then 28<br />
when 'MAR' then 31<br />
when ...<br />
when 'DEC' then 31<br />
end</code></p>
<p>That is a lot of code to write, and it doesn&#8217;t handle leap years. As it turns out there is a much easier way to approach this. All I need to do is recognize what the last day of every month has in common. It doesn&#8217;t matter if the day number is 28, 29, 30, or 31, there is always one constant: The day after the last day of one month is always the first day of the following month.</p>
<p>I can use the trunc() function to get the first day of this month. How can I get the first day of next month? I could try adding 30 days and then truncating, but that would still require me to know how many days are in each month in order to check the boundary conditions. It should not be that hard, and it turns out that I can get to the last day of a month using a new function called add_months(). </p>
<h3>Finding the End of a Month</h3>
<p>Here is the syntax for the add_months() function:</p>
<p><code>ADD_MONTHS(&lt;date&gt;, &lt;number_of_months&gt;)</code></p>
<p>The number_of_months can be either a positive or negative integer. This allows me to move either forwards or backwards for as many months at a time as are needed. What can I do with this? Suppose that I get the first day of this month, add one month to that date, and then subtract one day? Where do I end up? I end up on the last day of this month. I take something constant (the first day of a month) and use it to derive something that is dynamic (the last day of the month) with a little creative math. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So here is some code for an object named Last Day of Current Month that uses the add_months() function and the logic outlined in the prior paragraph:</p>
<p><code>add_months(trunc(sysdate,'MM'), 1) -1</code></p>
<p>This formula works for every month of the year, and every possible scenario of leap year as well. It will handle moving across a year boundary (December &#8211; January). It will handle the fact that some months have different numbers of days&#8230; for example, if I add one month to January 31 I will get February 28 (or 29 as appropriate). It will not add 31 days since January has 31 days. Here is a table showing some output from an Oracle query that shows what happens when I cross a month boundary using this function:</p>
<table class="blogtable">
<tr>
<th>Input Date</th>
<th>First Day of Month</th>
<th>Last Day of Month</th>
<th>+1 Month</th>
<th>-1 Month</tr>
<tr class="alt">
<td>28-AUG-07</td>
<td>01-AUG-07</td>
<td>31-AUG-07</td>
<td>28-SEP-07</td>
<td>28-JUL-07</td>
</tr>
<tr>
<td>29-AUG-07</td>
<td>01-AUG-07</td>
<td>31-AUG-07</td>
<td>29-SEP-07</td>
<td>29-JUL-07</td>
</tr>
<tr class="alt">
<td>30-AUG-07</td>
<td>01-AUG-07</td>
<td>31-AUG-07</td>
<td>30-SEP-07</td>
<td>30-JUL-07</td>
</tr>
<tr>
<td>31-AUG-07</td>
<td>01-AUG-07</td>
<td>31-AUG-07</td>
<td>30-SEP-07</td>
<td>31-JUL-07</td>
</tr>
<tr class="alt">
<td>01-SEP-07</td>
<td>01-SEP-07</td>
<td>30-SEP-07</td>
<td>01-OCT-07</td>
<td>01-AUG-07</td>
</tr>
<tr>
<td>02-SEP-07</td>
<td>01-SEP-07</td>
<td>30-SEP-07</td>
<td>02-OCT-07</td>
<td>02-AUG-07</td>
</tr>
<tr class="alt">
<td>03-SEP-07</td>
<td>01-SEP-07</td>
<td>30-SEP-07</td>
<td>03-OCT-07</td>
<td>03-AUG-07</td>
</tr>
<tr>
<td>04-SEP-07</td>
<td>01-SEP-07</td>
<td>30-SEP-07</td>
<td>04-OCT-07</td>
<td>04-AUG-07</td>
</tr>
</table>
<p>August has 31 days. September has 30. Notice what happens on August 31 when I add one month to the date? I get September 30, which is what I want to see. What Oracle does is provide a mapping of &#8220;last days&#8221; so that you get the expected results without having to do a lot of specific date checking. Adding a negative month also works as expected, which becomes important when I try to create objects for last month.</p>
<h3>It&#8217;s All About the Creative Process</h3>
<p>If you read and understood everything in the prior section, that&#8217;s great. Now throw it all away. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_lol.gif' alt=':lol:' class='wp-smiley' />  </p>
<p>The formula that I showed using add_months() works. It dates back to my early days as an Oracle developer. The need to find the last day of a month is so important that several versions back (I think in version 8? but I am not sure&#8230;) Oracle gave us a function to do exactly that. The function name, oddly enough, is last_day() and here is the syntax:</p>
<p><code>LAST_DAY(&lt;date&gt;)</code></p>
<p>Short, simple, and to the point. As I was writing this post I thought about skipping the add_months() example. I went ahead and included it to show the &#8220;creative process&#8221; that I try to apply to find an alternate path when no immediate solution presents itself. </p>
<h3>And for Last Month?</h3>
<p>I don&#8217;t want to stop after handling the current month. I want to be able to provide dynamic dates for the starting and ending dates for last month too. As I did in the weekly post I will use the @Select() function to reference the complex expressions that I have created so far and then subtract one month  as shown here. To get the end of last month no matter how many days there are in &#8220;this&#8221; month I will apply the last_day() function again.</p>
<p><code>add_months(@Select('Dynamic Dates\Start of This Month'), -1)<br />
last_day(add_months(@Select('Dynamic Dates\Start of This Month'), -1))</code></p>
<p>That&#8217;s all there is to it. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> </p>
<h3>What About Fiscal Calendar Periods?</h3>
<p>In order to provide dynamic dates for a fiscal calendar I would have to use a period calendar table or write custom database functions. The standard Oracle database functions work only on a standard calendar. If you have a fiscal calendar and require dynamic monthly dates I strongly suggest that you look at creating a calendar table that supports your requirements. <em>Note: I won&#8217;t be covering that process in this series of posts.</em></p>
<h3>Summary</h3>
<p>Over the past three posts I have built daily, weekly, and monthly dynamic date objects. I did not cover how to use these objects in a query in this post but I did in the first post, which is conveniently linked below. Remember that these objects are presented <strong>will not parse</strong> in Designer. They don&#8217;t reference a table and therefore will generate an error. As long as these objects are used with at least one &#8220;real&#8221; object on a query they will function perfectly fine.</p>
<p>I still have a few more posts to go before I wrap up this series. The next post will be fairly simple as it will include standard objects for working with the current year and prior year date ranges. You won&#8217;t have to wait until next year for that one to come out. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> </p>
<h3>Related Posts</h3>
<ul>
<li><a href="http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/">Dynamic Dates Part I: Yesterday and Today</a></li>
<li><a href="http://www.dagira.com/2007/08/30/dynamic-dates-part-ii-weekly-date-ranges/">Dynamic Dates Part II: Weekly Date Ranges</a></li>
<li><a href="http://www.dagira.com/category/design/dynamic-dates/">All posts in this series</a></li>
</ul>
<h3>Oracle functions used in this post</h3>
<ul>
<li>add_months() Returns an offset in months ahead or behind from the date given</li>
<li>last_day() Returns the last day of the month for the date given as an argument</li>
<li>to_char() Converts a date into a string value with a wide variety of formats</li>
<li>trunc() Returns a date value with the time truncated off</li>
<li>trunc( , &#8216;MM&#8217;) Returns a date value truncated to the first of the month</li>
</ul>
<h3>Dynamic Dates With Oracle Functions</h3>
<table class="blogtable">
<tr>
<th>Date</th>
<th>Formula</th>
</tr>
<tr class="alt">
<td>Today</td>
<td class="code">trunc(sysdate)</td>
</tr>
<tr>
<td>Yesterday</td>
<td class="code">trunc(sysdate-1)</td>
</tr>
<tr class="alt">
<td>Start of This Week</td>
<td class="code">next_day(trunc(sysdate-7), &#8216;Sunday&#8217;)</td>
</tr>
<tr>
<td>End of This Week</td>
<td class="code">next_day(case to_char(sysdate,&#8217;Day&#8217;) when &#8216;Saturday&#8217; then trunc(sysdate-1) else trunc(sysdate) end, &#8216;Saturday&#8217;)</td>
</tr>
<tr class="alt">
<td>Start of Last Week</td>
<td class="code">@Select(&#8217;Dynamic Dates\Start of This Week&#8217;) &#8211; 7</td>
</tr>
<tr>
<td>End of Last Week</td>
<td class="code">@Select(&#8217;Dynamic Dates\End of This Week&#8217;) &#8211; 7</td>
</tr>
<tr class="alt">
<td>Start of This Month</td>
<td class="code">trunc(sysdate,&#8217;MM&#8217;)</td>
</tr>
<tr>
<td>End of This Month</td>
<td class="code">last_day(trunc(sysdate))</td>
</tr>
<tr class="alt">
<td>Start of Last Month</td>
<td class="code">add_months(@Select(&#8217;Dynamic Dates\Start of This Month&#8217;) , -1)</td>
</tr>
<tr>
<td>End of Last Month</td>
<td class="code">last_day(add_months(@Select(&#8217;Dynamic Dates\Start of This Month&#8217;), -1))</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.dagira.com/2007/09/12/dynamic-dates-part-iii-monthly-date-ranges/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Dynamic Dates Part II: Weekly Date Ranges</title>
		<link>http://www.dagira.com/2007/08/30/dynamic-dates-part-ii-weekly-date-ranges/</link>
		<comments>http://www.dagira.com/2007/08/30/dynamic-dates-part-ii-weekly-date-ranges/#comments</comments>
		<pubDate>Thu, 30 Aug 2007 18:10:09 +0000</pubDate>
		<dc:creator>Dave Rathbun</dc:creator>
				<category><![CDATA[Dynamic Dates]]></category>
		<category><![CDATA[Universe Design]]></category>

		<guid isPermaLink="false">http://www.dagira.com/2007/08/30/dynamic-dates-part-ii-weekly-date-ranges/</guid>
		<description><![CDATA[Last Time On This Subject&#8230;
In the first post in this series I set up both regular objects and predefined condition objects that were based on the Oracle sysdate pseudo-column. These objects were designed to be used for scheduling reports with date conditions while allowing the date range to move forward in time for each new [...]]]></description>
			<content:encoded><![CDATA[<h3>Last Time On This Subject&#8230;</h3>
<p>In the <a href="http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/">first post</a> in this series I set up both regular objects and predefined condition objects that were based on the Oracle sysdate pseudo-column. These objects were designed to be used for scheduling reports with date conditions while allowing the date range to move forward in time for each new execution of the scheduled report. For that article I only created objects for Today and Yesterday. Today <img src='http://www.dagira.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  I will provide some weekly date ranges with the help of a few Oracle functions.</p>
<p><span id="more-24"></span></p>
<h3>Yesterday Once More</h3>
<p>Here is a review of what I ended up with for my daily objects in the prior post.</p>
<table class="blogtable">
<tr>
<th>Date</th>
<th>Formula</th>
</tr>
<tr class="alt">
<td>Today</td>
<td class="code">trunc(sysdate)</td>
</tr>
<tr>
<td>Yesterday</td>
<td class="code">trunc(sysdate-1)</td>
</tr>
</table>
<p>Where can we go from here? It turns out that time travel is possible, given the right functions. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Weekly Dates</h3>
<p>The first thing I need to decide is when my week starts. I will use a calendar where the week starts on Sunday and ends on Saturday. The function that I will use to derive those dates is called next_day(). The syntax for this function is:</p>
<p><code>NEXT_DAY(&lt;date&gt;, &lt;day of the week&gt;)</code></p>
<p>What this will do is take the input date and return the date of the &#8220;next&#8221; day based on the second function parameter. Let&#8217;s suggest that today is Tuesday. The next Saturday ( the end of the week) would be four days away. You could write a fancy case statement to determine that, but the next_day() function takes all the effort out of it. Simply write this:</p>
<p><code>next_day(trunc(sysdate), 'Saturday')</code></p>
<p>And the next thing you know, you have the date for the end of the current week. Or do you?</p>
<h3>Testing the Boundaries</h3>
<p>With any condition that involves a range it is important to check the boundaries. For example, what is the return value for the function outlined above if today is already Saturday? Unfortunately, it isn&#8217;t the correct Saturday. Instead, it will be the Saturday that ends the following week. That means that we have a formula that works for 6 out of the seven days of the week. How can I know that it is Saturday? I need a new function.</p>
<p>For this I will use the to_char() function. I don&#8217;t care what the date is, but I do need to know what the day is. The formula for that is:</p>
<p><code>to_char(sysdate,'Day')</code></p>
<p>If today is a Saturday, then the return value for this function is the day name Saturday. There are different argument options that can be used here&#8230; for example using &#8216;Dy&#8217; instead of &#8216;Day&#8217; would return Sat instead of Saturday. Either works for this purpose.</p>
<p>Now that I have a way to know if it is Saturday or not, I can handle my boundary condition. There are a couple of things that I can do. I have opted to check to see if it is Saturday, and if it is, back up one day before applying the next_day() function. Backing up one day changes sysdate to a Friday, and then the &#8220;next&#8221; Saturday would be the required date instead of a week later. Here&#8217;s the completed formula:</p>
<p><code>next_day(case to_char(sysdate,'Day') when 'Saturday' then trunc(sysdate-1) else trunc(sysdate) end, 'Saturday')</code></p>
<p>That code can be used to create an object called End of Current Week. This object can then be used in conditions as I outlined in the first post in this series.</p>
<h3>Start of Current Week</h3>
<p>To get to the start of the week I might like to use a previous_day() function. However Oracle does not provide that. Not to worry, there is a very simple solution. All I need to do is back up 7 days and then apply the next_day function to get the Sunday date that starts the current week.</p>
<p><code>next_day(trunc(sysdate-7), 'Sunday')</code></p>
<p>Since I had an issue with Saturday boundary condition I want to also check what happens on Sunday using the above formula. It turns out that we don&#8217;t have a problem. If today is any day other than Sunday, and I back up 7 days, then the next Sunday is the proper date. What if my current date is actually Sunday? After I back up 7 days, the &#8220;next&#8221; Sunday just brings me right back to where I started from. So while it might seem like extra work to go back a week just to come back to the same date value, the simple formula as posted above works just fine on the Sunday boundary condition. </p>
<p>Here is some sample data that shows what the output from these formulas will look like over a few weeks of data:</p>
<table class="blogtable">
<tr>
<th>Date</th>
<th>Day Name</th>
<th>Week Start Date</th>
<th>Week End Date</th>
</tr>
<tr class="alt">
<td>22-Aug-07</td>
<td>WED</td>
<td>19-Aug-07</td>
<td>25-Aug-07</td>
</tr>
<tr>
<td>23-Aug-07</td>
<td>THU</td>
<td>19-Aug-07</td>
<td>25-Aug-07</td>
</tr>
<tr class="alt">
<td>24-Aug-07</td>
<td>FRI</td>
<td>19-Aug-07</td>
<td>25-Aug-07</td>
</tr>
<tr>
<td>25-Aug-07</td>
<td>SAT</td>
<td>19-Aug-07</td>
<td>25-Aug-07</td>
</tr>
<tr class="alt">
<td>26-Aug-07</td>
<td>SUN</td>
<td>26-Aug-07</td>
<td>1-Sep-07</td>
</tr>
<tr>
<td>27-Aug-07</td>
<td>MON</td>
<td>26-Aug-07</td>
<td>1-Sep-07</td>
</tr>
<tr class="alt">
<td>28-Aug-07</td>
<td>TUE</td>
<td>26-Aug-07</td>
<td>1-Sep-07</td>
</tr>
<tr>
<td>29-Aug-07</td>
<td>WED</td>
<td>26-Aug-07</td>
<td>1-Sep-07</td>
</tr>
<tr class="alt">
<td>30-Aug-07</td>
<td>THU</td>
<td>26-Aug-07</td>
<td>1-Sep-07</td>
</tr>
<tr>
<td>31-Aug-07</td>
<td>FRI</td>
<td>26-Aug-07</td>
<td>1-Sep-07</td>
</tr>
<tr class="alt">
<td>1-Sep-07</td>
<td>SAT</td>
<td>26-Aug-07</td>
<td>1-Sep-07</td>
</tr>
<tr>
<td>2-Sep-07</td>
<td>SUN</td>
<td>2-Sep-07</td>
<td>8-Sep-07</td>
</tr>
<tr class="alt">
<td>3-Sep-07</td>
<td>MON</td>
<td>2-Sep-07</td>
<td>8-Sep-07</td>
</tr>
<tr>
<td>4-Sep-07</td>
<td>TUE</td>
<td>2-Sep-07</td>
<td>8-Sep-07</td>
</tr>
<tr class="alt">
<td>5-Sep-07</td>
<td>WED</td>
<td>2-Sep-07</td>
<td>8-Sep-07</td>
</tr>
<tr>
<td>6-Sep-07</td>
<td>THU</td>
<td>2-Sep-07</td>
<td>8-Sep-07</td>
</tr>
<tr class="alt">
<td>7-Sep-07</td>
<td>FRI</td>
<td>2-Sep-07</td>
<td>8-Sep-07</td>
</tr>
<tr>
<td>8-Sep-07</td>
<td>SAT</td>
<td>2-Sep-07</td>
<td>8-Sep-07</td>
</tr>
<tr class="alt">
<td>9-Sep-07</td>
<td>SUN</td>
<td>9-Sep-07</td>
<td>15-Sep-07</td>
</tr>
<tr>
<td>10-Sep-07</td>
<td>MON</td>
<td>9-Sep-07</td>
<td>15-Sep-07</td>
</tr>
<tr class="alt">
<td>11-Sep-07</td>
<td>TUE</td>
<td>9-Sep-07</td>
<td>15-Sep-07</td>
</tr>
</table>
<h3>I (Want to) Know What You Did Last Week</h3>
<p>Knowing what happened this week is interesting. But I won&#8217;t stop here. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  It is often more interesting to know what happened last week, since that week is done and in the books. So I would like to make objects named Start of Last Week and End of Last Week. Since I have the objects for this week built, the objects for last week are trivial. Here they are:</p>
<p>Start of Last Week<br />
<code>@Select('Dynamic Dates\Start of This Week') - 7</code></p>
<p>End of Last Week<br />
<code>@Select('Dynamic Dates\End of This Week') - 7</code></p>
<p>I plan to talk more about the @Select() function in a future post. For now I will just say that it is used to copy the select clause from another object referenced by the &#8216;Class Name\Object Name&#8217; format. Since the Start of Last Week is exactly 7 days prior to the Start of This Week, I think that this is a perfect opportunity to use that feature. Since I have already created the complicated formulas for the start and end of the current week, I can reuse them / adjust them for the last week values as well. Using this function means that future changes to the objects for this week will be inherited by the objects for last week at the same time.</p>
<h3>Summary</h3>
<p>I can easily extend the formulas that I have provided so far. At this point I have a Dynamic Dates class that contains objects for Today, Yesterday, Start of This Week, and End of This Week. To do &#8220;next week&#8221; I would add seven days to the current week objects instead of subtracting. If I wanted to be creative I could prompt the user for the &#8220;number of weeks&#8221; and end up with a set of objects that would allow a report to run for 2 weeks ahead or 3 weeks prior just by changing a prompt value. All of these objects are based on sysdate and therefore can be used to provide dynamic date conditions for any sort of report. Their expected use is for scheduled reports but I cannot see anything wrong with using them interactively as well. </p>
<p>Remember that these objects as presented <strong>will not parse</strong> in Designer. They don&#8217;t reference a table and therefore will generate an error. As long as these objects are used with at least one &#8220;real&#8221; object on a query they will function perfectly fine.</p>
<p>Days and weeks are generally the same no matter what type of calendar is being used. In the next post in this series I will talk about how to work with monthly boundaries. If you need to work with fiscal periods you will have to include a calendar table of some sort, but I can do months with standard functions. That post will be published&#8230; next month. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<h3>Related Posts</h3>
<ul>
<li><a href="http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/">Dynamic Dates Part I: Yesterday and Today</a></li>
<li><a href="http://www.dagira.com/category/design/dynamic-dates/">All posts in this series</a></li>
</ul>
<h3>Oracle functions used in this post</h3>
<ul>
<li>next_day() Returns the date of the next day based on the provided day name argument</li>
<li>to_char() Converts a date into a string value with a wide variety of formats</li>
<li>trunc() As used in this article it returns a date value with the time truncated off</li>
</ul>
<h3>Dynamic Dates With Oracle Functions</h3>
<table class="blogtable">
<tr>
<th>Date</th>
<th>Formula</th>
</tr>
<tr class="alt">
<td>Today</td>
<td class="code">trunc(sysdate)</td>
</tr>
<tr>
<td>Yesterday</td>
<td class="code">trunc(sysdate-1)</td>
</tr>
<tr class="alt">
<td>Start of This Week</td>
<td class="code">next_day(trunc(sysdate-7), &#8216;Sunday&#8217;)</td>
</tr>
<tr>
<td>End of This Week</td>
<td class="code">next_day(case to_char(sysdate,&#8217;Day&#8217;) when &#8216;Saturday&#8217; then trunc(sysdate-1) else trunc(sysdate) end, &#8216;Saturday&#8217;)</td>
</tr>
<tr class="alt">
<td>Start of Last Week</td>
<td class="code">@Select(&#8217;Dynamic Dates\Start of This Week&#8217;) &#8211; 7</td>
</tr>
<tr>
<td>End of Last Week</td>
<td class="code">@Select(&#8217;Dynamic Dates\End of This Week&#8217;) &#8211; 7</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.dagira.com/2007/08/30/dynamic-dates-part-ii-weekly-date-ranges/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Dynamic Dates Part I: Yesterday and Today</title>
		<link>http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/</link>
		<comments>http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 16:05:27 +0000</pubDate>
		<dc:creator>Dave Rathbun</dc:creator>
				<category><![CDATA[Dynamic Dates]]></category>
		<category><![CDATA[Universe Design]]></category>

		<guid isPermaLink="false">http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/</guid>
		<description><![CDATA[Hitting a Moving Target
Does anybody really know what time it is?
Does anybody really care?
If so I can&#8217;t imagine why&#8230;
With apologies to the rock group Chicago, but I could not help starting out this post with a quote from one of their most famous hit records. Yeah, I have records. Deal with it.  
I am [...]]]></description>
			<content:encoded><![CDATA[<h3>Hitting a Moving Target</h3>
<blockquote><p>Does anybody really know what time it is?<br />
Does anybody really care?<br />
If so I can&#8217;t imagine why&#8230;</p></blockquote>
<p>With apologies to the rock group Chicago, but I could not help starting out this post with a quote from one of their most famous hit records. Yeah, I have records. Deal with it. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p>
<p>I am going to start out this post with a very obvious statement. There are two ways to get reports: Interactive and Scheduled. Interactive reports can have prompts that allow me to specify which values I want to see, and many times those prompts will include dates or date ranges. Since they are interactive I can change the dates each time I run the report.</p>
<p>But what about scheduled reports? I would hardly want to schedule a report that always ran for August 22, 2007, right? I want that date parameter value to change. Maybe I want the report to always run for &#8220;yesterday&#8221; or &#8220;last week&#8221; or &#8220;the second Tuesday of the month&#8221; or anything along those lines. The challenge is, of course, that the value for &#8220;yesterday&#8221; changes each day I run the report. How do I hit that moving target?</p>
<p><span id="more-23"></span></p>
<h3>It&#8217;s All About Today</h3>
<p>The first component that I need to solve this issue is knowing what &#8220;today&#8221; means for any given database. Every system that I have worked with has provided at least one mechanism to get today&#8217;s date:</p>
<table class="blogtable">
<tr>
<th>Database</th>
<th>Function or Token</th>
</tr>
<tr class="alt">
<td>DB2</td>
<td>current date</td>
</tr>
<tr>
<td>Oracle</td>
<td>sysdate</td>
</tr>
<tr class="alt">
<td>Informix</td>
<td>TODAY</td>
</tr>
<tr>
<td>MySQL</td>
<td>CURDATE()</td>
</tr>
<tr class="alt">
<td>SQL Server</td>
<td>getdate()</td>
</tr>
<tr>
<td>Sybase</td>
<td>getdate()</td>
</tr>
<tr class="alt">
<td>Teradata</td>
<td>DATE</td>
</tr>
</table>
<p>Some databases use a function and others provide a token or pseudo-column instead. I am going to use Oracle syntax for the rest of this post but the general concepts and techniques that I plan to show are often able to be ported to other database systems.</p>
<h3>Using sysdate</h3>
<p>As mentioned I can get today&#8217;s date from Oracle using the pseudo-column sysdate. (It&#8217;s called a pseudo-column because you can get it from any table in the database.) Once I know what today is I can derive other interesting values. The first step is often to get only the date (instead of a full date/time result) and the Oracle function trunc() takes care of that. So today can be obtained by:</p>
<p><code>trunc(sysdate)</code></p>
<p>The trunc() function in Oracle is an <em>overloaded</em> function which means I can use it with a variety of different syntaxes. (It may be that I could create a more portable version of the same objects using the cast() function.) Now that I have today, what can I do with it? I mentioned earlier in this post that one of the common requests is to be able to run a report for &#8220;yesterday&#8221; on a scheduled basis. Yesterday is the day before today on most calendars. <img src='http://www.dagira.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  So I can create an object for &#8220;yesterday&#8221; using either of the following:</p>
<p><code>trunc(sysdate-1)<br />
trunc(sysdate)-1</code></p>
<p>Both of these will return the exact same result, so it doesn&#8217;t matter which one I pick. I am going to use the first one for reasons that will be detailed in a future blog post.</p>
<h3>Conditions in a Scheduled Document</h3>
<p>Once these objects are created I have a couple of options to consider. First, I can make predefined conditions that are based on a specific date object like Order Date or Shipped Date. I will often do this for frequently used conditions. But an important option that should not be overlooked is creating a simple object called Yesterday with the code posted above. After this object is created then I can create any date condition, using any date object in the universe, by using the &#8220;Select an Object&#8221; query operand. This option is available in full client from version 5.x forward (and possibly in version 4.x too, I don&#8217;t remember). It is also available in Web Intelligence XI and might be in 6.5.</p>
<p>I will create Today and Yesterday objects using Oracle as my target database. Here are the objects:</p>
<p><img src="/tips/dynamic_dates_part_01/001_today_object_definition.jpg" width="450" height="325" border="0" alt="Today Object Definition" title="Define the Today dynamic object" /></p>
<p><img src="/tips/dynamic_dates_part_01/002_yesterday_object_definition.jpg" width="450" height="326" border="0" alt="Yesterday Object Definition" title="Define the Yesterday dynamic object" /></p>
<p>And here is the result I get when I parse either of these two objects:</p>
<p><img src="/tips/dynamic_dates_part_01/003_parse_results.jpg" width="375" height="111" border="0" alt="Parse Results" title="Parse Results" /></p>
<p>This is typical! Most if not all of my objects built for this strategy will fail to parse. One of my current universes has several hundred objects that fail to parse during a universe integrity check, and that is just fine. I don&#8217;t want to reference any table with these objects (not even the special Oracle &#8220;dual&#8221; table) because then I would be limited as to how I can use them. If I use the dual table and don&#8217;t include any joins then I would get Cartesian warnings. Objects like this are perfectly safe to use as long as they participate in a query with at least one object that does use a real table. And since these objects would never be used by themselves that is okay.</p>
<p>Now that I have my objects built, here&#8217;s how I will use them. I am going to build a condition that will return all orders entered yesterday by using the following steps.</p>
<ol>
<li>Create a condition on Order Date Equal to and select Object from the condition operand options.</p>
<p><img src="/tips/dynamic_dates_part_01/010_query_filter_on_object.jpg" width="369" height="152" border="0" alt="Building the query filter" title="Building the query filter" /></li>
<li>Browse the universe to my Dynamic Dates for Scheduling class and select Yesterday.
<p><img src="/tips/dynamic_dates_part_01/011_query_filter_select_object.jpg" width="350" height="425" border="0" alt="Select the object" title="Select the object for the query filter" /></li>
<li>Confirm the selection and review the condition.
<p><img src="/tips/dynamic_dates_part_01/012_query_filter_equal_yesterday.jpg" width="265" height="53" border="0" alt="Order date equal yesterday" title="Order date equal to Yesterday" /></li>
</ol>
<p>That generates a condition that looks just perfect for my purposes. The order date will be compared to a dynamic &#8220;yesterday&#8221; object. Since that object is based on the system date then that object will change in value on each new daily execution of the scheduled report. If order dates are date/time values then to get the full range I can use a between operator instead. For this I need both of my dynamic date objects, as shown next. This condition will return everything from midnight yesterday to midnight today.</p>
<p><img src="/tips/dynamic_dates_part_01/013_query_filter_between_dates.jpg" width="385" height="56" border="0" alt="Order date between yesterday and today" title="Order date between Yesterday and Today" /></p>
<p>What does the SQL code look like?<br />
<code>SELECT<br />
  CUSTOMER.CUSTID,<br />
  ...<br />
  sum(ORD.TOTAL)<br />
FROM<br />
  CUSTOMER,<br />
  ORD<br />
WHERE<br />
  ( CUSTOMER.CUSTID=ORD.CUSTID  )<br />
  AND<br />
  <strong>ORD.ORDERDATE  BETWEEN  trunc(sysdate-1) AND trunc(sysdate)</strong><br />
GROUP BY<br />
  CUSTOMER.CUSTID</code></p>
<p>The condition added to the where clause by this condition is <strong>bold</strong> to try to make it stand out more. I can see that there is no specific date in the query, therefore as the report instance is executed on its daily scheduled basis I will get what I expect: a daily report with orders from yesterday.</p>
<h3>Predefined Conditions</h3>
<p>The biggest advantage to creating the general date objects is that they can be used to compare against any other date object in the universe. Of course I can also consider creating predefined condition objects in my universe. These objects are often built for conditions that are too complex for users to create, or there is a need for consistency across all reports, or for convenience. But in this case the number of predefined condition objects could become a challenge.</p>
<p>I would have to create a cross product of date objects, dynamic date elements, and desired date operators. That&#8217;s a lot of predefined conditions in my universe! <img src='http://www.dagira.com/wp-includes/images/smilies/icon_eek.gif' alt=':shock:' class='wp-smiley' />  So far I have two dates (order date and ship date) and two dynamic elements (today and yesterday). I could have:</p>
<ol>
<li>Order Date Equal To Today</li>
<li>Order Date Equal To Yesterday</li>
<li>Order Date Between Yesterday and Today</li>
<li>Order Date &#8230; ?</li>
</ol>
<p>As you can see it could get out of hand. And all of the conditions above can be created by the user with the proper query techniques if I just build the dynamic objects. In theory you could build a huge set of predefined conditions. In practice I generally will build one or two that are used frequently and let the user do the rest. So I will create objects for orders placed yesterday and for orders shipped yesterday and leave it at that until I get requests for something different.</p>
<p><img src="/tips/dynamic_dates_part_01/020_predefined_orders_yesterday.jpg" width="450" height="325" border="0" alt="Orders entered yesterday" title="Orders entered Yesterday" /></p>
<p><img src="/tips/dynamic_dates_part_01/021_predefined_shipped_yesterday.jpg" width="450" height="327" border="0" alt="Orders shipped yesterday" title="Orders shipped Yesterday" /></p>
<h3>Summary</h3>
<p>This is one of the standard elements of any universe that I design. This post is designed to introduce the concepts. The next post in this series will cover some more Oracle-specific date functions and how they can be used to do very creative things with dynamic date objects for scheduling.</p>
<h3>Oracle functions used in this post</h3>
<ul>
<li>trunc() As used in this article it returns a date value with the time truncated off</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dagira.com/2007/08/22/dynamic-dates-part-i-yesterday-and-today/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
	</channel>
</rss>

