Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Displaying text in a formula Post Reply Post New Topic
Author Message
kmundt
Newbie
Newbie


Joined: 26 Jan 2011
Online Status: Offline
Posts: 7
Quote kmundt Replybullet Topic: Displaying text in a formula
    Posted: 26 Jan 2011 at 2:11pm
Hello. I'm using Crystal Reports 11.5 and have a question about displaying text in a formula. I don't have much experience with CR and it all seems quite confusing to me so any help is appreciated.
 
I have the following formula in my report:
 
if
    {COMPLIANCEDATE.COMPLIANCEDATE}="immediately" then CurrentDate + 1
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="3 days" then CurrentDate + 3
else if
    {COMPLIANCEDATE.COMPLIANCEDATE} ="7 days" then CurrentDate + 7
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="10 days" then CurrentDate + 10
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="14 days" then CurrentDate + 14
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="30 days" then CurrentDate + 30
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="60 days" then CurrentDate + 60
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="CUSTOM" then {NOTICE.CUSTOM_COMPLIANCE};
 
 
Currently, when I select "immediately" from the list I get tomorrow's date i.e. "01-27-11" from the CurrentDate +1 command.
 
What I want to display is the word "Immediately" when I select "immediately" instead. Is there an easy way to modify the formula so it displays this word/text instead of the date?  All other selections should remain displaying the date (as they already do).
 
Just FYI, the "Custom" selection picks an arbitrary date that does not meet the +3, +7, +10, etc criteria.
 
Thanks in advance.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 27 Jan 2011 at 3:24am
instead of the CurrentDate + x, since this is returning a datetime data type, use TOTEXT(CurrentDate + x, "MM/dd/yyyy")  [or whatever formatting you want for the date], then you can return the string 'Immediately' in the formula without error as all paths will return the same data type, namely, string.
 
HTH
IP IP Logged
kmundt
Newbie
Newbie


Joined: 26 Jan 2011
Online Status: Offline
Posts: 7
Quote kmundt Replybullet Posted: 27 Jan 2011 at 6:44am
lockwelle,
 
Well that was (pretty) easy. At first, I received an error re: the custom date but after applying the same change there too it's working like I wanted it to. This is what I have now:
 
if
    {COMPLIANCEDATE.COMPLIANCEDATE}="immediately" then TOTEXT("IMMEDIATELY")
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="3 days" then TOTEXT(CurrentDate + 3, "MM-dd-yyyy")
etc., etc.
else if
    {COMPLIANCEDATE.COMPLIANCEDATE}="CUSTOM" then TOTEXT ({NOTICE.CUSTOM_COMPLIANCE}, "MM-dd-yyyy"); 
 
 
I remember reading all data types needed to be the same in a formula but didn't know how to format it to make it do what I wanted.
 
Anyway, thanks for the help!


Edited by kmundt - 27 Jan 2011 at 6:46am
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.