I have an issue trying to retrieve fiscal data from my database. For example, the table I am using to calculate data between months has the month and the fy year (i.e. 1112 (Nov 2012)). When I try to calculate the AMT Due data between the months Oct - Dec there is no data that is calculated. However, when I calculate the data between Jan - Sept, it has no problem but fails to incorporate the data from the beginning of the fy(OCT NOV DEC) resulting with inaccurate data.
M_Y Amt Due dept FY
1112 362.44 D2 2013
1212 10.50 D4 2013
0213 55.55 D1 2013
@LF = CAST((CAST@Current_FY_IN AS INT)-1) AS CHAR)
@startdate = @LFy + '10'
@enddate = CASE SUBSTRING(@mon_IN,1,1) WHEN '1' THEN @LY+@mon_IN ELSE @Current_FY_IN+@month_IN
@Current_FY_IN (i.e. 2013)
END
I know the issue, I just can't seem to fix this problem. I would love any ones input on this matter.
SELECT M_Y, ISNULL(SUM(Amt Due),0) AS AmtDueNow
FROM FYAmmountDue
WHERE
'20' + RIGHT(M_F,2) + LEFT(M_F,2) BETWEEN @startdate AND @enddate - 1
AND FY = @Current_FY_IN