From dePoPo.net

Compare a string field as a date on a crytal report

Posted in: Crystal Reports
By dePoPo
Jan 26, 2010 - 10:21:15 AM

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.

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



© Copyright 2010 by dePoPo.net