Compare a string field as a date on a report

This formula can be used to compare a string field in a database against the current date and time on a crystal report. Place the formula in the Selection expert / Details. Rows where the date and time contained in the string field falls before the current date and time will be supressed. Note that it is usualy better to handle this kind of selections server side on de the SQL server, because in this scenario the entire data set is passed to the report.

' --- Crystal reports compare string field to current date/time
if date({Q_DatabaseQuery.FieldName}) >= currentdatetime then true
  • the function date({Q_DatabaseQuery.FieldName}) converts your string field in the database to a date variabale
  • the funtion CurrentDateTime returns the current date and time of execution of the report