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()