Wednesday, March 7, 2012

Dynamic Date Range

For some parameters i have in a report, i need it to use the first day of the month and the last day of the month.
The problem is that i need the variable that returns these values, i need them to be dynamic so that i can have them sent out as a subscription
For example here are my parameters and what i need them to equal

@.StartDate=@.FirstDayOfThisMonth<--Does a variable like this exist?
@.EndDate=@.LastDayOfThisMonth<-Same here i need this sort of variable

Or if there is a way to somehow retrieve this value, I know how to do it in vb.net but i need it for the subscription

Thanks For any help you can giveI havent used subscriptions so I dont know how they work but you can write custom code in vb.net and use the value in the report..doesnt that work ?|||it may, how would you go about doing that. Where do you create the code, and where do you place it?|||

write a vb.net function that will return what you want (the first day of the month) and put it in the code tab under Report -> Properties > code tab. from your report you can call the function as = Code.functionname( Fields!Parameter1.Value, Fields!Parameter2.Value )

You can also loook up books online for some samples..

|||

I hope this can be helpful fro you:

SELECT DATEADD(d, -1*DAY(GETDATE())+1, GETDATE()) FirstDayMonth,DATEADD(d, -1*DAY(GETDATE())-1, DATEADD(m, 1, GETDATE())) LastDayMonth

No comments:

Post a Comment