raghuldrag (7/26/2016)
Hi Friends,Without setting a financial year start and end date I wanna get the output
i.e
the user takes a report from '01-jun-2010' and '30-jun-2010' (only input from the user),
we have to calculate financial year through the user input
does this help ?
DECLARE @mth_st DATETIME = '20100601';
DECLARE @mth_nx DATETIME = DATEADD(MONTH,1,@mth_st);
DECLARE @year INT
IF (MONTH(@mth_st) >= 4)
SET @year = YEAR(@mth_st)
ELSE
SET @year = YEAR(@mth_st) - 1
DECLARE @yr_st DATETIME = DATEADD(MONTH, 3, DATEADD(YEAR, DATEDIFF(YEAR, 0, DATEADD(YEAR, @year - 1900, 0)) , 0))
DECLARE @yr_nx DATETIME = DATEADD(YEAR,1,@yr_st);
PRINT @mth_st;
PRINT @mth_nx
PRINT @yr_st;
PRINT @yr_nx;
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day