Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Field Formula

Status
Not open for further replies.

mikew777

Technical User
Nov 16, 2004
2
US
Hi I am trying to create a formula that will only select records with a date greater than 01/01/2005.

The date is held in the field (test.opn_dt)in the format dd/mm/yyyy hh:mm:ss

However I am getting the error "A date-time is required here"

When I run the below:

if {test.grp_cd} = "TTTT" and {test.opn_dt} >= "01/01/2005 00:00:00" then "OK"

Help would be greatly appreciated

Mike
 
You haven't told it that this is a date, nor given it the normal format. Try {test.opn_dt} >= Date(2005, 1, 1). Or {test.opn_dt} >= DateTime(2005, 1, 1, 0, 0) if time matters.

If that doesn't work, try displaying {test.opn_dt} on the report, to see what it actually does contain. If it is actually a string based on a date, you'll need to make it a date in order to use it. Try Cdate({test.opn_dt}) - Crystal is smart about conversions, but display the result to see what you get.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
If your field is datetime type it cannot be compare with a string

try

{test.opn_dt} >= DateTime (2005,01,01,00,00,00 )

Mo
 
Brilliant it was the DateTime I was missing, am still quite new to Crystal so I really appreciate the help from you both.

Thanks again
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top