Skip to Content
0
Nov 03, 2020 at 06:37 AM

Crystal report date record selection formula gives an error.

74 Views Last edit Nov 03, 2020 at 06:50 AM 4 rev

I use the following code to feed a record selection formula to a report. I'm using VB.Net and MS SQL Server. "exp_date" is a date type column (Ex: 2021-10-25). getServerDateTime() is my own function to get the server date. "Impersonate" loads the login details to the report. I get the attached error when I'm running this code. What am I doing wrong here?

                Case "Expired Batches"


                    Dim crepExpIt As New crepExpiered
                    Dim curDate As Date = Format(getServerDateTime().Today)  
                    CReportAuthentication.Impersonate(crepExpIt) 
                    crepExpIt.RecordSelectionFormula = "{TB_STOCK.exp_date} <=#" & curdate & "#"
                    CrystalReportViewer1.ReportSource = crepExpIt
                    CrystalReportViewer1.Zoom(85)
                    CrystalReportViewer1.Refresh()
                    CrystalReportViewer1.RefreshReport()

Attachments

capture.png (7.9 kB)
table-data.png (3.1 kB)