I have query, grouping data by hour using<br>Group by DatePart(hour, TheDateField)<br><br>I need to group records by the half hour - <br>I cant use: Group by DatePart(minute,The DateField)<br><br>Has anyone got a suggestion.<br><br>regards
Oracle solution:<br>You can use a column like:<br><b>DECODE sign(TO_NUMBER(TO_CHAR(TheDateField,'MIN'))-30,1,'To','Past')</b>, combined with the column which extracts the hour. So you get 2 columns for the <b>group by</b> clause. Of course, using aq more complicated formula you can combine those 2 columns in a single one, but you can try my solution. <p>Eduard Stoleru<br><a href=mailto:e_stoleru@yahoo.com>e_stoleru@yahoo.com</a><br><a href= > </a><br>
Sorry, I'm correcting my answer. You should read:<b><br>DECODE(sign(TO_NUMBER(TO_CHAR(TheDateField,'MI'))-30),1,'To','Past')</b>. So, you can get 'To' value for minutes in 31..59, 'Past value for minutes in 0..30. If you want other partition, you can alter the DECODE statement like <b>DECODE(sign(TO_NUMBER(TO_CHAR(TheDateField,'MI'))-30),1,'To',-1,'Past','Half')</b> <p>Eduard Stoleru<br><a href=mailto:e_stoleru@yahoo.com>e_stoleru@yahoo.com</a><br><a href= > </a><br>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.