Link to home
Start Free TrialLog in
Avatar of Paula Ward
Paula Ward

asked on

CRYSTAL REPORTS IF STATEMENT WITH DATE AND TEXT

I need a formula that will return a null date 1/1/1900 with the character "~".   This is what I have so far, but it comes back with an error says that a Date and Time are Required Here.

if {UPR00100.DEMPINAC} <> #1/1/1900# then {UPR00100.DEMPINAC} else "~"

I need the result to be the date or "~"
Avatar of Ido Millet
Ido Millet
Flag of United States of America image

An IS statement MUST return the same data type on both branches.

If one of the branches requires a text ("~") you should convert the date in the other branch to text as well.  Use the ToText() function for that.
Avatar of Paula Ward
Paula Ward

ASKER

I have tried several combinations of the ToText function, but I am doing something wrong.  I don't usually have to do this sort of thing.  Any chance you can give me that formula using my formula above.
Thanks in advance.
ASKER CERTIFIED SOLUTION
Avatar of Ido Millet
Ido Millet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ido is correct (naturally :-).  I'll just add that you can add an argument to the ToText function to control the format of the date (and time, if it's a datetime field) in the string.  If the default format isn't what you want, look for ToText in the CR Help.

 James
Just realized what James comment meant.  I need to add the argument to change the date format to YYYYMMDD before it goes ToText.  Can you tell me how to do that?
thanks
if {UPR00100.DEMPINAC} = #1/1/1900# then "~" ELSE ToText({UPR00100.DEMPINAC}, 'yyyyMMdd')
I don't have CR installed on this machine, but I think Ido's got it.  And, like I said, you should be able to look up ToText in the CR Help to see a complete list of the formatting options.

 James