I have a table where I store order dates YYYY-MM_DD.
How do I create fiscal year and fiscal quarter with the following requirements: Fiscal years:
Fiscal Quarters:
I tried
WHERE OrderDate BETWEEN '1999-07-01' and '2001-06-31'
DATEADD (month,7,OrderDate) AS [OrderDateNew],
DATEPART(Year, [OrderDateNew]) as [FY],
DATEPART(QUARTER, dateadd(month,3,[OrderDateNew])) as [FQ]
I am getting some very odd results. Any help is highly appreciated.
Output should be something like:
FY FQ Some other data columns of products, sales etc
2000 1
2000 2
2000 3
2000 4
2001 1
2001 2
2001 3
2001 4
Just add six months and use the year. For instance, if you want FY 2000:
where year(dateadd(month, 6, orderdate)) = 2000
If you want the FY year and quarter, use the same idea:
select year(dateadd(month, 6, orderdate)) as fyear,
datepart(quarter, dateadd(month, 6, orderdate)) as fquarter