<?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/"
	>

<channel>
	<title>Cyril Hanquez &#187; User Interface</title>
	<atom:link href="http://cyrilhanquez.com/blog/category/user-interface/feed/" rel="self" type="application/rss+xml" />
	<link>http://cyrilhanquez.com/blog</link>
	<description>Rich Internet Application developer</description>
	<lastBuildDate>Mon, 07 Jun 2010 08:12:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>SpatialKey Technology Preview</title>
		<link>http://cyrilhanquez.com/blog/2008/08/07/spatialkey-technology-preview/</link>
		<comments>http://cyrilhanquez.com/blog/2008/08/07/spatialkey-technology-preview/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 12:07:45 +0000</pubDate>
		<dc:creator>Cyril H.</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Mapping]]></category>
		<category><![CDATA[User Interface]]></category>
		<category><![CDATA[Universal Mind]]></category>

		<guid isPermaLink="false">http://cyrilhanquez.com/blog/?p=114</guid>
		<description><![CDATA[&#160; Doug McCune and Universal Mind just announced the launch their new baby,  SpatialKey, a geospatial information visualization product. If you have enough of those markers on web-based maps, you will love SpatialKey :  you will be able to render heatmaps, heat grids or graduated circles by just uploading a simple CSV files ! As [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fcyrilhanquez.com%252Fblog%252F2008%252F08%252F07%252Fspatialkey-technology-preview%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22SpatialKey%20Technology%20Preview%22%20%7D);"></div>
<p style="text-align: justify;">&nbsp;<BR><img class="alignleft size-full wp-image-117" style="padding-right:5px" title="SpatialKey" src="http://cyrilhanquez.com/blog/wp-content/uploads/2008/08/spatialkey.png" alt="" width="160" height="120" /> <strong><a title="Doug McCune " href="http://dougmccune.com" target="_blank">Doug McCune</a></strong> and <strong><a title="Universal Mind" href="http://universalmind.com/" target="_blank">Universal Mind</a></strong> just announced the launch their new baby,  <strong><a title="SpatialKey" href="http://www.spatialkey.com/" target="_blank">SpatialKey</a></strong>, a geospatial information visualization product.</p>
<p style="text-align: justify;">If you have enough of those markers on web-based maps, you will love SpatialKey :  you will be able to render <strong>heatmaps</strong>, <strong>heat grids</strong> or <strong>graduated circles</strong> by just uploading a simple CSV files ! As a technology preview, we have only access to a  small part of the capabilities of SpatialKey, but it&#8217;s already so AWESOME !</p>
<p style="text-align: justify;">The demos include four visualization templates :<strong> Animation/Playback</strong>, <strong>Map Comparison</strong>, <strong>Drill Down</strong> and <strong>Temporal Heat Index</strong>. I was really impressed by the <em>Wal-Mart store openings (1962 &#8211; 2005)</em> demo (just click the play button <img src='http://cyrilhanquez.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ), the <em>Sacramento crimes (November 2007)</em> drill down demo but also the <em>BrightKite check-ins (April 28 &#8211; May 19, 2008)</em> demo. Check the <a href="http://www.spatialkey.com/spatialkey/www/gallery/gallery_home.cfm" target="_blank"><strong>Gallery</strong></a>.</p>
<p style="text-align: justify;">There will be different solutions available :</p>
<ul>
<li><strong>SpatialKey Personal</strong>, that will let you easily import your own data.</li>
<li><strong><a href="http://spatialkey.com/spatialkey/www/solutions/solutions_home.cfm#enterprise" target="_blank">SpatialKey Enterprise</a></strong>, that will let you load a data set of any size.</li>
<li><strong><a href="http://lawenforcement.spatialkey.com/" target="_blank">SpatialKey Law Enforcement Dashboard</a></strong>, enterprise version of SpatialKey specifically targeted toward police departments.</li>
<li><strong>SpatialKey Custom Solutions</strong></li>
</ul>
<p>For more details, read <strong><a href="http://dougmccune.com/blog/2008/08/06/announcing-spatialkey-geographic-information-without-limits/" target="_blank">Doug&#8217;s blog post</a></strong>, go to the <strong><a href="http://www.spatialkey.com" target="_blank">SpatialKey website</a></strong> <strong>(join the beta !)</strong> and read their <strong><a href="http://blog.spatialkey.com/" target="_blank">dedicated blog</a></strong>. I cannot wait to be able to use my own set of datas especially when I read [...]</p>
<blockquote><p>Early this Fall, we will release a desktop AIR application that allows you to load your own geotemporal datasets (through an importer that geocodes addresses if necessary) into the visualization templates</p></blockquote>

]]></content:encoded>
			<wfw:commentRss>http://cyrilhanquez.com/blog/2008/08/07/spatialkey-technology-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A lovely way to group dates</title>
		<link>http://cyrilhanquez.com/blog/2008/07/16/a-lovely-way-of-grouping-dates/</link>
		<comments>http://cyrilhanquez.com/blog/2008/07/16/a-lovely-way-of-grouping-dates/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 22:37:59 +0000</pubDate>
		<dc:creator>Cyril H.</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://cyrilhanquez.com/blog/?p=35</guid>
		<description><![CDATA[In my current Flex project I need to create an interface that will replace the email client of the users. Many of them are using Outlook, so I would like to reproduce the same look and behavior. The new advanced datagrid in Flex 3 will come in handy to achieve the task, but there is one specific behavior [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fcyrilhanquez.com%252Fblog%252F2008%252F07%252F16%252Fa-lovely-way-of-grouping-dates%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22A%20lovely%20way%20to%20group%20dates%22%20%7D);"></div>
<p style="text-align: justify;">In my current Flex project I need to create an interface that will replace the email client of the users. Many of them are using Outlook, so I would like to reproduce the same look and behavior. The new advanced datagrid in Flex 3 will come in handy to achieve the task, but there is one specific behavior that I would like to reproduce, it&#8217;s the way Outlook is grouping the dates : it creates the following groups :</p>
<ul>
<li>
<div style="text-align: justify;"><strong>Today</strong></div>
</li>
<li>
<div style="text-align: justify;"><strong>Yesterday</strong></div>
</li>
<li>
<div style="text-align: justify;"><strong>&lt;NAME OF DAY&gt;</strong> <em>- if in the same week as the current date</em></div>
</li>
<li>
<div style="text-align: justify;"><strong>Last Week</strong></div>
</li>
<li>
<div style="text-align: justify;"><strong>Two Weeks ago</strong></div>
</li>
<li>
<div style="text-align: justify;"><strong>Last Month</strong></div>
</li>
<li>
<div style="text-align: justify;"><strong>Older</strong></div>
</li>
</ul>
<p style="text-align: justify;">It&#8217;s also easily expendable to the Future (Tomorrow, In two days&#8230;). So I created an Oracle function which generate the correct group label for a given date.</p>
<p><span id="more-35"></span></p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;"><span style="color: #00F;">CREATE</span> <span style="color: #00F;">OR</span> <span style="color: #000;">REPLACE</span> <span style="color: #00F;">PACKAGE</span> TRIS_UTILS <span style="color: #00F;">AUTHID</span> CURRENT_USER <span style="color: #00F;">AS</span>
<span style="color: #080; font-style: italic;">/*******************************************************************
NAME:      TRIS_UTILS
PURPOSE:   Utilities functions.
REVISION:  Ver        Date            Author          Description
          -----     -------     ---------------  ------------------
           1.0    15/07/2008    Cyril Hanquez    Creation  
*******************************************************************/</span>
&nbsp;
<span style="color: #080; font-style: italic;">/* compare a_date with sysdate and return
    the corresponding group label            */</span>  
<span style="color: #00F;">FUNCTION</span> get_grouping_date_name<span style="color: #00F;">&#40;</span>a_date <span style="color: #00F;">IN</span> <span style="color: #00F;">DATE</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">RETURN</span> <span style="color: #00F;">VARCHAR2</span><span style="color: #00F;">;</span>
&nbsp;
<span style="color: #00F;">END</span> TRIS_UTILS<span style="color: #00F;">;</span>
<span style="color: #00F;">/</span>
&nbsp;
<span style="color: #00F;">CREATE</span> <span style="color: #00F;">OR</span> <span style="color: #000;">REPLACE</span> <span style="color: #00F;">PACKAGE</span> <span style="color: #00F;">BODY</span> TRIS_UTILS <span style="color: #00F;">AS</span>
<span style="color: #080; font-style: italic;">/*******************************************************************
NAME:      TRIS_UTILS
PURPOSE:   Utilities functions.
REVISION:  Ver        Date            Author          Description
          -----     -------     ---------------  ------------------
           1.0    15/07/2008    Cyril Hanquez    Creation  
*******************************************************************/</span>
<span style="color: #00F;">FUNCTION</span> get_grouping_date_name<span style="color: #00F;">&#40;</span>a_date <span style="color: #00F;">IN</span> <span style="color: #00F;">DATE</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">RETURN</span> <span style="color: #00F;">VARCHAR2</span> <span style="color: #00F;">IS</span>
&nbsp;
return_var <span style="color: #00F;">VARCHAR2</span><span style="color: #00F;">&#40;</span><span style="color: #800;">50</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">;</span>
&nbsp;
<span style="color: #00F;">BEGIN</span>
&nbsp;
<span style="color: #00F;">CASE</span>
   <span style="color: #080; font-style: italic;">/* In Oracle date1-date2 returns a number of days
      It's equivalent to DATEDIFF(day, a_date, getdate()) */</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #000;">TRUNC</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">0</span>
       <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Today'</span><span style="color: #00F;">;</span>
   <span style="color: #080; font-style: italic;">/* parameter 'IW' is returning the Week of year
      but we must also verify that we are in a valid period */</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">0</span> <span style="color: #00F;">AND</span>
            <span style="color: #080; font-style: italic;">/* between -6 AND +6 would be enough
               7 days a week -1 because today returns 0
               equivalent to ABS(TRUNC(SYSDATE - a_date)) &lt;= 8 */</span>
            <span style="color: #000;">TRUNC</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">BETWEEN</span> <span style="color: #00F;">-</span><span style="color: #800;">8</span> <span style="color: #00F;">AND</span> <span style="color: #800;">8</span><span style="color: #00F;">&#41;</span>
       <span style="color: #00F;">THEN</span>
       <span style="color: #00F;">CASE</span>
          <span style="color: #00F;">WHEN</span> <span style="color: #000;">TRUNC</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">1</span>
             <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Yesterday'</span><span style="color: #00F;">;</span>
          <span style="color: #00F;">WHEN</span> <span style="color: #000;">TRUNC</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #00F;">-</span><span style="color: #800;">1</span>
             <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Tomorrow'</span><span style="color: #00F;">;</span>
          <span style="color: #00F;">WHEN</span> <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&gt;</span> <span style="color: #800;">1</span>
             <span style="color: #080; font-style: italic;">/* We are returning the Name of day here */</span>
             <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #000;">INITCAP</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'DAY'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">;</span>
       <span style="color: #00F;">END</span> <span style="color: #00F;">CASE</span><span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">1</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* &lt;=13 would be enough */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">15</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Last Week'</span><span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #00F;">-</span><span style="color: #800;">1</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* &lt;=13 would be enough */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">15</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Next Week'</span><span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">2</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* &lt;=20 would be enough */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">22</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Two Weeks Ago'</span><span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #00F;">-</span><span style="color: #800;">2</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* &lt;=20 would be enough */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">22</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'In Two Weeks'</span><span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">3</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* &lt;=27 would be enough */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">29</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Three Weeks Ago'</span> <span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'IW'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #00F;">-</span><span style="color: #800;">3</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* &lt;=27 would be enough */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">29</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'In Three Weeks'</span><span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'MM'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'MM'</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">1</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* current month + 1 month so a maximum of 62 days */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">62</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Last Month'</span> <span style="color: #00F;">;</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #00F;">&#40;</span><span style="color: #00F;">&#40;</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span><span style="color: #00F;">,</span><span style="color: #F00;">'MM'</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">-</span><span style="color: #000;">TO_CHAR</span><span style="color: #00F;">&#40;</span>a_date<span style="color: #00F;">,</span><span style="color: #F00;">'MM'</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #00F;">-</span><span style="color: #800;">1</span> <span style="color: #00F;">AND</span>
           <span style="color: #080; font-style: italic;">/* current month + 1 month so a maximum of 62 days */</span>
           <span style="color: #000;">ABS</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">&lt;=</span> <span style="color: #800;">62</span><span style="color: #00F;">&#41;</span><span style="color: #00F;">&#41;</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Next Month'</span><span style="color: #00F;">;</span>
   <span style="color: #080; font-style: italic;">/* in other cases just check if the date is in the future... */</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #000;">SIGN</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #00F;">-</span><span style="color: #800;">1</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Further'</span><span style="color: #00F;">;</span>
   <span style="color: #080; font-style: italic;">/* ...or in the past */</span>
   <span style="color: #00F;">WHEN</span> <span style="color: #000;">SIGN</span><span style="color: #00F;">&#40;</span><span style="color: #000;">SYSDATE</span> <span style="color: #00F;">-</span> a_date<span style="color: #00F;">&#41;</span> <span style="color: #00F;">=</span> <span style="color: #800;">1</span>
      <span style="color: #00F;">THEN</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'Older'</span><span style="color: #00F;">;</span>
   <span style="color: #080; font-style: italic;">/* if the date is null, do something */</span>
   <span style="color: #00F;">ELSE</span> return_var <span style="color: #00F;">:=</span> <span style="color: #F00;">'---'</span><span style="color: #00F;">;</span>
<span style="color: #00F;">END</span> <span style="color: #00F;">CASE</span><span style="color: #00F;">;</span>
&nbsp;
<span style="color: #00F;">RETURN</span> return_var<span style="color: #00F;">;</span>
&nbsp;
<span style="color: #00F;">END</span><span style="color: #00F;">;</span>
&nbsp;
<span style="color: #00F;">END</span> TRIS_UTILS<span style="color: #00F;">;</span>
<span style="color: #00F;">/</span></pre></div></div>

<p style="text-align: justify;">Now that we have our group labels generated, we should take care about the sorting. Its quite easy in fact, just use the DATEDIFF. To test it just use the following SQL :</p>

<div class="wp_syntax"><div class="code"><pre class="plsql" style="font-family:monospace;"><span style="color: #00F;">SELECT</span> <span style="color: #00F;">&lt;</span>your_date<span style="color: #00F;">&gt;</span> <span style="color: #00F;">AS</span> MY_DATE<span style="color: #00F;">,</span>
TRIS_UTILS<span style="color: #00F;">.</span><span style="color: #00F;">&#40;</span>get_grouping_date_name<span style="color: #00F;">,&lt;</span>your_date<span style="color: #00F;">&gt;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">AS</span> <span style="color: #00F;">GROUP</span> LABEL<span style="color: #00F;">,</span>
<span style="color: #00F;">&#40;</span>SYSDATE<span style="color: #00F;">-&lt;</span>your_date<span style="color: #00F;">&gt;</span><span style="color: #00F;">&#41;</span> <span style="color: #00F;">AS</span> DATE_SORT
<span style="color: #00F;">FROM</span> DUAL</pre></div></div>

<p style="text-align: justify;">In a next blog post I will share the Flex code that I wrote to generate the &#8220;Outlook like&#8221; interface. Feel free to comment and suggest any enhancement <img src='http://cyrilhanquez.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

]]></content:encoded>
			<wfw:commentRss>http://cyrilhanquez.com/blog/2008/07/16/a-lovely-way-of-grouping-dates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
