We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,434 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Get Data by Fiscal (Financial Year) from sql server

Hi everyone,
I have database which has data of past 2 years.
I want to get that data for current financial year.
(Here financial year is 1st april to 31st of March)


This query returns data for current calender year i.e. [Jan-to-Dec]

SELECT DATENAME(MONTH, DATE) AS MonthName, 
  SUM(NetAMOUNT) AS dsfd from SALESMASTER
  GROUP BY DATEPART(MONTH, DATE), DATENAME(MONTH, DATE)
  ORDER BY DATEPART(MONTH, DATE)

I want to see the same data in the form of financial year i.e. [April-to-March]


just take care financial year involves 9 months of previous year and 3 months of current year.

please reply..

4
Contributors
3
Replies
1 Year
Discussion Span
1 Year Ago
Last Updated
4
Views
Question
Answered
hitro456
Light Poster
36 posts since Dec 2009
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

You may check the posts here and see it is helpful for you:
http://www.bigresource.com/Tracker/Track-ms_sql-8xeNr2qA/

Thanks.

catherine sea
Junior Poster
126 posts since Jan 2008
Reputation Points: 25
Solved Threads: 22
Skill Endorsements: 0

how is the date stored, if stored using a date object or a timestamp its a piece of cake
if its stored using text dates, punch out your dbase designer

almostbob
Nearly a Senior Poster
3,303 posts since Jan 2009
Reputation Points: 585
Solved Threads: 403
Skill Endorsements: 7
Question Answered as of 3 Years Ago by catherine sea and almostbob

DECLARE @StartDate DATETIME

DECLARE @EndDate DATETIME

SET @StartDate = DATEADD(dd,0, DATEDIFF(dd,0, DATEADD( mm, -(((12 + DATEPART(m, getDate())) - 4)%12), getDate() ) - datePart(d,DATEADD( mm, -(((12 + DATEPART(m, getDate())) - 4)%12),getDate() ))+1 ) )

SET @EndDate = DATEADD(SS,-1,DATEADD(mm,12,@StartDate))


SELECT @StartDate,@EndDate

Conficker111111
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.7717 seconds using 2.66MB