1.11M Members

Get Data by Fiscal (Financial Year) from sql server

 
0
 

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..

 
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

Question Answered as of 4 Years Ago by catherine sea and almostbob
 
0
 

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

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article