Date Parameter

Last post 07-21-2008 1:39 PM by danny123. 5 replies.
Page 1 of 1 (6 items)
Active Topics My Discussions Unanswered Sort Posts: Previous Next
  • 07-03-2008 1:55 PM

    Date Parameter

    Hi there,

    I am writing a simple report using SSRS 2005 where user selects the start date and end date , and data which was added between start date and end date is displayed.

    I created to date parameters and user can select dates from there. The issue is SSRS is allowing user to select the End date which is prior to selected Start Date. Is there a way i can specify or force user to select End date after Start date.

     Thanks

    Danny

  • 07-03-2008 1:59 PM In reply to

    • satya
    • Top 10 Contributor
    • Joined on 11-05-2002
    • United Kingdom
    • Posts 22,515
    • Microsoft MVP
      Moderator

    Re: Date Parameter

    -Satya S K J

    SQL Server MVP



    Knowledge is Power, you will gain by sharing it. SSQA.net - Invisible contributions to the users & visible success in SQL Community.
  • 07-03-2008 6:22 PM In reply to

    Re: Date Parameter

    I dont think you can force it. However you can show a message on header if the end date is less than start date

    Madhivanan

    Failing to plan is Planning to fail
  • 07-08-2008 5:07 AM In reply to

    • satya
    • Top 10 Contributor
    • Joined on 11-05-2002
    • United Kingdom
    • Posts 22,515
    • Microsoft MVP
      Moderator

    Re: Date Parameter

    I believe you could do a function to validate the parameters

    -Satya S K J

    SQL Server MVP



    Knowledge is Power, you will gain by sharing it. SSQA.net - Invisible contributions to the users & visible success in SQL Community.
  • 07-21-2008 10:54 AM In reply to

    Re: Date Parameter

    Hi Satya,

    Thanks for the support. I did use the custom code but i could not figure out how to assosiate that code with parameter as i could not  find any place where i can set the properties for the parameter for validation.

    Please advise.

     

  • 07-21-2008 1:39 PM In reply to

    Re: Date Parameter

    Hi there,

    I got this working. Following is the method i used to make it work in case someone else is in same situation :

    You need to add a function to validate the parameters.

    Go to the Report Properties under the Report menu and place this code to the Code Tab.

    Public Function CheckDate(SDate as Date, EDate as Date) as Integer
    Dim msg as String
         msg = ""
         If (SDate > EDate)  Then
     msg="Start Date should not be later than End Date"
         End If
         If msg <> "" Then
     MsgBox(msg, 16, "Parameter Validation Error")
     Err.Raise(6,Report)                    'Raise an overflow
         End If
    End Function

    Then go to the Report Parameters and Add named it XXX with the datatype is string. Checked the Hidden and Allow blank value ckeckboxes. In Available Values choose Non-Queried and from Default Values  choose Non-Queried in right side of textbox then press the FX button then paste this code.

    =CODE.CheckDate(<parameterStartdate>.Value,<parameterEnddate>.Value) 

    Then press OK.

    Thanks

     

Page 1 of 1 (6 items)
Active Topics   My Discussions    Unanswered Posts


© 2000 - 2007 vDerivatives Limited All Rights Reserved.