Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: String and Date Concatenation in IF function Post Reply Post New Topic
Author Message
Achilles
Newbie
Newbie


Joined: 15 Nov 2012
Location: Australia
Online Status: Offline
Posts: 1
Quote Achilles Replybullet Topic: String and Date Concatenation in IF function
    Posted: 15 Nov 2012 at 4:00pm
Hi Everyone,

Bear with me I am a newbie here.

I have an If function that returns both string and numeric result and the numeric result doesn't come up. See below:

Formula 1:  
if Left({SOP10201.SOPNUMBE},3)="INV" then "-na-" else "Days-"&({@Aged_to_Report_Date}-{@TransferAged})

My objective here is if the first condition is correct put "-na-" but if not show the numeric result.

The formula on it's own  is working but as soon as I put them in IF function the negative part (i.e., show the number) is not showing.

No errors of the IF formula when I click Check button.

Formula 2:
if Left({SOP10201.SOPNUMBE},3)="INV" then "-na-" else ({@Aged_to_Report_Date}-{@TransferAged})

If I modify forumula 1 as shown in formula 2 an error occurs when i try to save it...it says...A string is required here...

Both {@Aged_to_Report_Date}-{@TransferAged} are results of date calculations shown as numbers.

By the way I am using Crystal 8.5.

Please help.



Edited by Achilles - 15 Nov 2012 at 4:07pm
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 15 Nov 2012 at 6:03pm
Hi
When you use IF condition, it always returns either numeric values or String values you can't have both in one IF statement.
 
Try this :
 
if Left({SOP10201.SOPNUMBE},3)="INV" then "-na-" else "Days-"&
 
or
 
if Left({SOP10201.SOPNUMBE},3)="INV" then 0 else ({@Aged_to_Report_Date}-{@TransferAged})
 
After placing this formula in your report, right click on it and go in format field --common tab--Display string --formula editor and give the follwing condition :
 
if Currentfieldvalue = 0 then "NA" else Totext(currentfieldvalue)
 
 
 
 
Thanks,
Sastry
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.033 seconds.