Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Calculate Quarter from Fiscal Date

Author  Topic 

micnie_2020
Posting Yak Master

232 Posts

Posted - 2012-12-13 : 22:07:06
Hi All,

Let said my Fiscal Year Start From Apr 12.

Calculation will start Apr/12. How to get below calculation:-

Q1 Apr/12-Jun/12
Q2 Jul/12-Sep/12
Q3 Oct/12-Dec/12
Q3 Jan/13-Mar/13

Please advise.

Thank you.

Regards,
Micheale

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-12-14 : 03:04:12
[code]
declare @fiscal_year_start date

select @fiscal_year_start = '2012-04-01'

select Q_start = dateadd(quarter, q - 1, @fiscal_year_start),
Q_end = dateadd(quarter, q, dateadd(day, -1, @fiscal_year_start))
from (
select q = 1 union all
select q = 2 union all
select q = 3 union all
select q = 4
) q[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -