Friday, February 24, 2012

date default parameter

Hello,

I have a date Start and End parameters. I want to set default value as previous quarters start and end date, how can I do this?

Thanks,

When you are passing the parameters to the report put the values there like
in reportpath = /<RerportDir>/ReportName&startdate=01/01/2005&enddate=01/03/2005
Hope this will solve U'r problem|||

hi JIM.H

Create a start & end date parameter and paste this code in the SRS code page and pass it today's date or a date entered by the user. This will return the Qtr's as I can understand from u'r question

PublicFunction parmQTRStartDate(ByVal currentDateAs DateTime)As System.DateTime

Dim iCurrentMonthAsInteger

' mm/dd/yyyy is format

iCurrentMonth = currentDate.Month()

SelectCase iCurrentMonth' Evaluate Number.

Case 1To 3' in First Quater return Previous Year

Return System.Convert.ToDateTime("09/01/" & currentDate.AddYears(-1).Year.ToString())

Case 4To 6' Second Quater in Return 1 Qtr

Return System.Convert.ToDateTime("01/01/" & currentDate.Year.ToString())

Case 7To 9' Third Quater in Return 2 Qtr

Return System.Convert.ToDateTime("04/01/" & currentDate.Year.ToString())

Case 10To 12' Fourth Quater in Return 3 Qtr

Return System.Convert.ToDateTime("07/01/" & currentDate.Year.ToString())

EndSelect

EndFunction

PublicFunction parmQTREndDate(ByVal currentDateAs DateTime)As System.DateTime

' mm/dd/yyyy is format

Dim iCurrentMonthAsInteger

iCurrentMonth = currentDate.Month()

SelectCase iCurrentMonth' Evaluate Number.

Case 1To 3' in First Quater return Previous Year

Return System.Convert.ToDateTime("12/31/" & currentDate.AddYears(-1).Year.ToString())

Case 4To 6' Second Quater in Return 1 Qtr

Return System.Convert.ToDateTime("03/31/" & currentDate.Year.ToString())

Case 7To 9' Third Quater in Return 2 Qtr

Return System.Convert.ToDateTime("06/30/" & currentDate.Year.ToString())

Case 10To 12' Fourth Quater in Return 3 Qtr

Return System.Convert.ToDateTime("09/30/" & currentDate.Year.ToString())

EndSelect

EndFunction
,Cheers
l0n3i200n

No comments:

Post a Comment