Sunday, August 31, 2014

Shared Dataset for SSRS - Data Defaults


Again...I am just trying to add an additional line to my code that is similar to the other statements in the sample I provided. I am not looking to rewrite or alter the original code at all.


What you are suggesting does not actually get me what I want. Your query is giving me every single day in a year or date range. That is not what I originally asked for. Again, if you look at my original post, I am only concerned with the CURRENT DATE. Your code just returns the components of a date. Could be useful in some other case, but not in mine.


Please refer back to my original post to see what I'm referring to.




A. M. Robinson



So are you looking out for this?



DECLARE @StrDt datetime='20140101'

;With CTE
AS
(
SELECT @StrDt AS Dt
UNION ALL
SELECT Dt + 1
FROM CTE
WHERE Dt+1 <'20150101'
)
SELECT CASE WHEN DATEADD(dd,DATEDIFF(dd,0,Dt)/7*7,-1) < @StrDt THEN @StrDt ELSE DATEADD(dd,DATEDIFF(dd,0,Dt)/7*7,-1) END
FROM CTE
GROUP BY DATEADD(dd,DATEDIFF(dd,0,Dt)/7*7,-1)

OPTION (MAXRECURSION 0)



I've just given example for one year but you can extend to any number of years you want




Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://ift.tt/19nLNVq http://ift.tt/1iEAj0c


No comments:

Post a Comment