All pastes #288956 Raw Edit

Untitled

public text v1 · immutable
#288956 ·published 2006-12-22 19:00 UTC
rendered paste body
select
distinct
case
	when month(Date) between 1 and 3 then
		cast(year(Date) as varchar) + 'Q1'
	when month(Date) between 4 and 6 then
		cast(year(Date) as varchar) + 'Q2'
	when month(Date) between 7 and 9 then
		cast(year(Date) as varchar) + 'Q3'
	when month(Date) between 10 and 12 then
		cast(year(Date) as varchar) + 'Q4'
end as FromDate,
case
	when month(Date) between 1 and 3 then
		'1/1/' + cast(year(Date) as varchar)
	when month(Date) between 4 and 6 then
		'4/1/' + cast(year(Date) as varchar)
	when month(Date) between 7 and 9 then
		'6/1/' + cast(year(Date) as varchar)
	when month(Date) between 10 and 12 then
		'9/1/' + cast(year(Date) as varchar)
end as FromDate,
case
	when month(Date) between 1 and 3 then
		'3/31/' + cast(year(Date) as varchar)
	when month(Date) between 4 and 6 then
		'6/30/' + cast(year(Date) as varchar)
	when month(Date) between 7 and 9 then
		'9/30/' + cast(year(Date) as varchar)
	when month(Date) between 10 and 12 then
		'12/1/' + cast(year(Date) as varchar)
end as ToDate
from news