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

Recommended Answers

All 4 Replies

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

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

How to do that in NO SQL -Mongodb to get unique data in Financial period.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.