When I try
DECLARE @yr AS date;
SET @yr = dbo.DateSerial(YEAR(GETDATE()), 6, 30)
SELECT [@yr]=@yr
here (using the source for DateSerial that you posted in your other thread here) I get:
2015-06-30
and NOT just "2015"
I tried declaring @yr as INT, but I then get an error attempting to assigning DateSerial to @yr
I just want to double check that you got just "2015" in the earlier test?
May not be the answer to the right question?? but you can get "year" like this:
SELECT DateAdd(Year, DateDiff(Year, 0, GetDate()), 0)
That will give you 01-Jan for the current year. You could then add 6 months -1 days to that to get 30-June:
SELECT DateAdd(Day, -1, DateAdd(Month, 6, DateAdd(Year, DateDiff(Year, 0, GetDate()), 0)))
BUt ... I can;t see anything wrong with your DateSerial function, and it seems the issue is with the @YR variable and the
p.EndDate >= @yr
test, so using a different "Date Calculation Formula" is probably not the answer.