开发者

Fiscal Year - Grab a list

I need to grab a list of all the fiscal years...E.g From November-October. I'm not sure if this is the correct solution:

  SELECT DISTINCT YEAR([date received]) AS [YEAR]  
    FROM [inventory]  
UNION AL开发者_如何学CL  
  SELECT  MAX(YEAR([date received])) + 1 AS [YEAR]  
    FROM [inventory]  
ORDER BY YEAR DESC  
GO


Your solution looks good. Depending on the data, you might include the first calendar year, which may not have data associated with it as a fiscal year. For example, if your first date is December 1, 2009, your first fiscal year is 2010. Your solution will include 2009.

Here's a query that may work for you

SELECT DISTINCT YEAR(DATEADD(mm, 2, [date received])) as [FISCAL_YEAR]
FROM [inventory]
ORDER BY [FISCAL_YEAR]

It gets the year value after shifting by 2 months (November becomes January).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜