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

Evaluating data when a field is equal to a value then insert effective date of value

Status
Not open for further replies.

4JH88J

Technical User
Jan 6, 2021
5
FM
Hi,

I am working on a report. I have inserted a textbox and I am trying to do a formula for this text box where if the value of a field equals to 130 then insert the effective date of the value into the text box.

this is what i have so far.

if {table.field} = 130 then {table.effective_dt} else blank

please help.

4JH88J
 

Looks like the issue is you want your result to be either a Date Format if the first field = 130, or a Text format if its not.

You need both result options to be the same type of field. Wrapping the date in a 'totext' makes them both text, but then you want to be able to format the result as a date I expect.
Wrapping the whole "If" statement in a CDATE will make this happen.

Create a formula of:
CDATE(
IF {table.field} = 130 then totext({Table.effective_dt}) else ''
)

NOTE - By wrapping a Convert to Date format (CDATE) around the formula, this turns the result of the formula back from Text into a Date Field (either a date or a blank), which you can then format using date formats once you drag it onto the Crystal Report screen (not into a text box)
After you've formatted it, if you need to, you can then drag it into the text box
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top