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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If then else on date field 1

Status
Not open for further replies.

Kevinski

Technical User
Jan 4, 2001
95
NZ
Info7

I'm trying to create a formula which checks a date field, if the date is <= Currentdate return a blank string ' ', else return the date.

I'm getting an error saying a strng is required after the 'else' and before the field name

Formula is:

if {purchase_order_line.po_line_date_expected} <= CurrentDate
then ' '
else {purchase_order_line.po_line_date_expected}

What am I doing wrong?
 
The alternative results of the formula must be of the same datatype, so if {purchase_order_line.po_line_date_expected} is a date field, then try:

if {purchase_order_line.po_line_date_expected} <= CurrentDate
then Date(0,0,0) else {purchase_order_line.po_line_date_expected}

-LB

 
Or in Crystal 8.5, you could do

if {purchase_order_line.po_line_date_expected} <= CurrentDate
then ' '
else totext({purchase_order_line.po_line_date_expected})

You can also do totext({your.date}, &quot;dd MMM yyyy&quot;) and other formats for date and time.

Depending on your database, it may be a good idea to do an isnull test first.


Madawc Williams
East Anglia, Great Britain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top