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 2005 Forums
 Transact-SQL (2005)
 Fiscal Year, Month

Author  Topic 

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-04-16 : 17:21:17
Greetings,

Based on the following link

[url]http://en.wikipedia.org/wiki/Fiscal_year#United_States[/url]

How can Get for
YEAR(d.Date) AS Fiscal_Year,
DATEPART(Quarter, d.Date) AS Fiscal_Quarter,
MONTH(d.Date) AS Fiscal_Month

Thanks!

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion

kunal.mehta
Yak Posting Veteran

83 Posts

Posted - 2009-04-17 : 02:25:34
Hi,
Please provide some test data and output format so that one can help u
KUNAL
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-04-17 : 03:33:58
[code]DECLARE @Sample TABLE
(
dt DATETIME
)

INSERT @Sample
SELECT '20080901' UNION ALL
SELECT '20081001' UNION ALL
SELECT '20081101' UNION ALL
SELECT '20081201' UNION ALL
SELECT '20090101' UNION ALL
SELECT '20090201' UNION ALL
SELECT '20090301' UNION ALL
SELECT '20090401' UNION ALL
SELECT '20090501' UNION ALL
SELECT '20090601' UNION ALL
SELECT '20090701' UNION ALL
SELECT '20090801' UNION ALL
SELECT '20090901' UNION ALL
SELECT '20091001' UNION ALL
SELECT '20091101' UNION ALL
SELECT '20091201'

SELECT dt,
DATEPART(YEAR, fy) AS Fiscal_Year,
DATEPART(QUARTER, fy) AS Fiscal_Quarter,
DATEPART(MONTH, fy) AS Fiscal_Month
FROM (
SELECT dt,
DATEADD(MONTH, 3, dt) AS fy
FROM @Sample
) AS d[/code]

E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

yosiasz
Master Smack Fu Yak Hacker

1635 Posts

Posted - 2009-04-17 : 10:32:32
Thanks very much Peso.
Sorry I did not provide some data KUNAL .

<><><><><><><><><><><><><><><><><><><><><><><><><>
If you don't have the passion to help people, you have no passion
Go to Top of Page
   

- Advertisement -