Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

What I'm trying to do should be simple I think, though I'm having difficultly finding appropriate tutorials or instruction.

 

Ideally I'd like to have the user enter in two dates, both a "From_Date" and "To_Date". I would then like to display each record that falls within that range in Crystal Reports.

 

I'm not asking anybody to do it all for me (though if you showed me a working example I wouldn't complain), I just really need some guidance. Any book or tutorial recommendations that you might have are also very welcome.

 

Thanks,

Kevin

Posted

rep = New CrystalReport

rep.RecordSelectionFormula = "{tblName.dateColumn} >= Date(" & startDate & ") AND {tblName.dateColumn} <= Date(" & endDate & ")"

 

where startDate and endDate are strings in format yyyy,mm,dd

 

Hope this helps

Posted

Forgive me, but there must be something basic that I need to do to in order to get this to work. I appreciate your time and patience.

 

I execute this code on a button click event, and when I click it right now nothing happens. It doesn't crash, but it doesn't bring back any results either. I'm positive that the date range is present in the database I'm testing on.

 

This is the code I have right now, which is essentially just what you gave me.

 

Dim startDate As String
       Dim endDate As String

       startDate = txtStartDate.Text
       endDate = txtEndDate.Text

       Dim rep = New CrystalReport()
       rep.RecordSelectionFormula = "{Shipping.DATE} >= Date(" & startDate & ") AND {Shipping.DATE} <= Date(" & endDate & ")"

Posted

And let me ask you this:

 

Does the date format that I enter in the search need to match the database date format? Or is it always necessary to use yyyy/mm/dd for the Date function?

 

Would it be problematic if my database data format does not match the yyyy/mm/dd?

Posted

I guess i assumed you are already trying to use the crystalreportviewer control.

Try adding CRV.reportsource = rep.

 

The date format in the db shouldn't matter, however the format that is being passed to crystal must be in the previously mentioned format. Of course the type must be a date in the db. The date being passed to crystal is comma separated not "/".

  • 2 years later...
Posted

I cant get mine to work!!

 

Hi this is my first post in these forums. Hello Everyone.

 

Im using a SQL server database and the DateReported column is a date and time field.

 

My code looks like this:

 

rpt.DataDefinition.RecordSelectionFormula = "CDate({VehicleDefect.DateReported}) >= Date(" + startDate.Year + "," + startDate.Month + "," + startDate.Day + ") AND CDate({VehicleDefect.DateReported}) <= Date(" + endDate.Year + "," + endDate.Month + "," + endDate.Day + ")"

 

after I had read the above posts but I get error:

 

Message: "Cast from string "CDate({VehicleDefect.DateReporte" to type 'Double' is not valid."

 

Can somebody please asist me in making this work!!

 

Thanks very much

 

Darren

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...