Saturday, 9 November 2013

Converting months into Quarters.



Create Quarters from Date


There are probably many ways to do this, but I would use the built in date
functions such as:

extract(month,[date]) which will give you the numeric month.
then do a case statement such as: 


case extract(month,[date])
when 1 then 1st  
when 2 then 1st  
when 3 then 1st  
when 4 then 2nd
When 5 then 2nd
When 6 then 2nd
When 7 then 3rd  
When 8 then 3rd  
When 9 then 3rd  
When 10 then 4th
When 11 then 4th  
When 12 then 4th
end 

Now you will have a dataitem which contains the quarter.
You can use it as you desire.
 

No comments:

Post a Comment