View report between FROM and TO Date[RESOLVED]
Hello everybody,
I have a table "ActivityLog" which tracks all the activities of the users. For viewing ActivityLog, I am using crystal report. I need to select "From" and "To" date from Form with DatePicker control and show the activities within these dates.
How do I pass "From" and "To" date to the crystal report as parameter.
Thanks.
Re: View report between FROM and TO Date
Are you using an ADO Recordset as a DataSource? If so you can just modify your sql query to
include a where clause that will limit the records to between the two dates.
Re: View report between FROM and TO Date
If you are using a selection formula in CR, create two parameters and add them to
your selection formula. Then pass the two parameters like in my link's example.
CR Parameter
Re: View report between FROM and TO Date
I am using SelectionForumula like this:
Code:
swotreportDoc.Load( Application.StartupPath.ToString() + "\\Reports\\ActivityLogReport2.rpt");
swotreportDoc.Refresh();
swotreportDoc.RecordSelectionFormula = "{ActivityLogForReport.Time} >=" + fromDateTimePicker.Value + " And {ActivityLogForReport.Time} <=" + toDateTimePicker.Value;
swotcrystalReportViewer.ReportSource = swotreportDoc;
How do I add parameter in crystal report ??
Thanks
Re: View report between FROM and TO Date
I resolved the problem with this selection formula.
Code:
swotreportDoc.RecordSelectionFormula = "CDate({ActivityLogForReport.Time}) >= Date(" + fromDateTimePicker.Value.Year + "," + fromDateTimePicker.Value.Month + "," + fromDateTimePicker.Value.Day + ") And CDate({ActivityLogForReport.Time}) <= Date(" + toDateTimePicker.Value.Year + "," + toDateTimePicker.Value.Month + "," + toDateTimePicker.Value.Day + ")";