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 "~"
if {UPR00100.DEMPINAC} <> #1/1/1900# then {UPR00100.DEMPINAC} else "~"
I need the result to be the date or "~"
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.
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
James
ASKER
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
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
James
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.