Search code examples
databasecrystal-reportsreportreportingcrystal-reports-2010

Formula seeking a date in Crystal Reports


So I am in a new job, and my predecessor had this automated report built in Crystal go out every month. The report recently broke, due to this code in the record selection formulas section.

{V_ITEM_MASTER.USER_FIELD_7} <> "" and
Date({V_ITEM_MASTER.USER_FIELD_7}) <= CurrentDate

The error it gives me is "bad string" for the Date({V_ITEM_MASTER.USER_FIELD_7}) and 'date expected' for CurrentDate.

What I think the problem is:

The field USER_FIELD_7 is not always a date. It is a string in this instance

Questions: 1) What does '<>' mean in Crystal? 2) Why would my predecessor try to bring up a date from a field clearly not always used for dates? Should I try to use the standard Crystal or even VB.net datetime methods instead?

Thanks!


Solution

  • <> is the "not equal to" operator.

    You can protect yourself against cases where the column doesn't contain a Date by using the IsDate() function. IF IsDate({V_ITEM_MASTER.USER_FIELD_7}) ...