Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2006
    Posts
    8

    Unanswered: Passing Date Ranges from ASP to Crystal 8.5

    I write this pass date ranges, but no data shows because I am not passing any dates. Only Employee ID shows on my report. I pass two parameters -

    1. Employee ID
    2. Date Range with a start and end.

    Code:
    'This line sets the DiscreetOrRangeKind to 1. For Ranged parameters the constant is 1.
        session("oRpt").ParameterFields.GetItemByName("RangedDateParameter").DiscreteOrRangeKind = 1
    
        'This line uses the AddCurrentRange method which takes three arguments.
        ' AddCurrentRange LowerBoundValue, UpperBoundValue, CRRangeInfoConstant
        'The CRRangeInfoConstant of 3 indicates that the range should include values greater than or equal to
        'the lower bound and less than or equal to the upper bound.
    
        'Reformat the start date to that of Crystal
        splitStartDate = split(strStartDate, "/")
        MyStartDate = splitStartDate(2) & "/" & splitStartDate(0) & "/" & splitStartDate(1) & " 12:00:00 AM"
    
        'Reformat the end date to that of Crystal
        splitEndDate = split(strEndDate, "/")
        MyEndDate = splitEndDate(2) & "/" & splitEndDate(0) & "/" & splitEndDate(1) & " 12:00:00 AM"
    
        session("oRpt").ParameterFields.GetItemByName("RangedDateParameter").AddCurrentRange CDate(MyStartDate),CDate(MyEndDate),CDbl("3")
    Please do let me if I am using the right range methods.

    Thanks.

  2. #2
    Join Date
    Oct 2006
    Posts
    8
    Anybody who has worked with Date Ranges....please do respond.

    Thanks.

  3. #3
    Join Date
    Sep 2006
    Posts
    30
    hi
    instead of taking the parameter fields u can directly send the date value whic is captured from the front end and u can sort the records based on them.
    ex: sel ={table1.date}>='01/10/2006' (date captured from the frontend)and {table1.date}<='25/10/2006'
    where sel is the condition string which u have to pass to the crystal report viewer

  4. #4
    Join Date
    Oct 2006
    Posts
    8
    Can you please assist me here:

    I get these from the form in my ASP page:

    Code:
    'Request for the startDate
    strStartDate = Request.form("StartDate")
    
    'Request for the endDate
    strEndDate = Request.form("EndDate")
    In the Record Selection Formula editor, I have this:

    Code:
    {AMP.EmpID} = {?EmpId} and
    {AMP.DateOfPost} in{?Post Date Range} and
    {AMP.DateOfPost} > Date (2006,1,1)
    Where AMP is the table name
    and DateOfPost is the column name.

    So within the ASP page, is this the way, I am supposed to write the code:

    Code:
    'This line creates an object to reference the 1st parameter in the report. 
    '{?Post Date Range}
    
    'Passing	date range to the Crystal Report Viewer.
    sel ={AMP.DateOfPost}>= CDate(strStartDate) and {AMP.DateOfPost}<= CDate(strEndDate)
    
    
    'EmpID which is numeric should be equal to ?EmpID. Hence cast as double of type number 7. (See the chart below)
    
    Set MyParam3 = session("Param").Item(3)
    MyNewParamValue3 = strEmpID
    Call MyParam3.SetCurrentValue(CDbl(MyNewParamValue3), 7)
    However the date taken by Crystal in the format of YYYY/MM/DD

    For single date parameter reports, I used to do this:

    Code:
    Set MyParam1 = Session("Param").Item(1)
    splitdate = split(Request.form("period"), "/")
    MynewDate1 = splitdate(2) & "/" & splitdate(0) & "/" & splitdate(1) & " 12:00:00 AM"
    MyParam1.SetCurrentValue CDate(MynewDate1)
    Do I do the same for Date Ranges too?

    Please do respond and mention if the above select string syntax is right or not?

    Thanks.

  5. #5
    Join Date
    Sep 2006
    Posts
    30
    u need to put the condition in single quotes like
    sel ='{AMP.DateOfPost}>= Date(strStartDate) and {AMP.DateOfPost}<= Date(strEndDate)' and u have to pass this to the crystal report viewer, u have to use Date() while passing a date field to the crystal reports.

  6. #6
    Join Date
    Oct 2006
    Posts
    8
    Hi,

    Can you send some sample code of ASP to pass date-ranges?

    I am confused as to how I am to write this in ASP

    This string:

    sel ='{AMP.DateOfPost}>= Date(strStartDate) and {AMP.DateOfPost}<= Date(strEndDate)'

    Do I just write this in the ASP and Crystal will grab this?

    I am asking because my crystal reports is not taking these values.

    There is a parameter in the report {?Post Date Range} in the report.

    Thanks.

  7. #7
    Join Date
    Oct 2006
    Posts
    8
    I am passing a start and end date from ASP to CR 8.5

    session("oRpt").RecordSelectionFormula = "{AMP.DateOfPost}>= Date(strStartDate) and {AMP.DateOfPost}<= Date(strEndDate)"

    When I do this, I get an error on the browser:

    Error Occurred Reading Records: The ) is missing.

    In the above formula,

    strStartDate and strEndDate are form variables:

    'Request for the startDate
    strStartDate = Request.form("StartDate")

    'Request for the endDate
    strEndDate = Request.form("EndDate")

    The format in the above form variables are

    mm/dd/yyyy

    Please suggest how I can rectify this selection formula syntax.

    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •