liquidspaces Posted July 15, 2003 Posted July 15, 2003 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 Quote
LostProgrammer Posted July 15, 2003 Posted July 15, 2003 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 Quote
liquidspaces Posted July 15, 2003 Author Posted July 15, 2003 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 & ")" Quote
liquidspaces Posted July 15, 2003 Author Posted July 15, 2003 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? Quote
LostProgrammer Posted July 15, 2003 Posted July 15, 2003 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 "/". Quote
liquidspaces Posted July 15, 2003 Author Posted July 15, 2003 LostProgrammer, Thank you so much. That works absolutely beautifully. Thanks again for your time and patience. I really appreciate it. Kevin Quote
shagracing Posted November 11, 2005 Posted November 11, 2005 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 Quote
shagracing Posted November 11, 2005 Posted November 11, 2005 Ive just seen the date!!! Don't expect any answers for this topic!!! lol :D Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.