Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Date formula Post Reply Post New Topic
Author Message
Karon
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 4
Quote Karon Replybullet Topic: Date formula
     Posted: 27 Jan 2010 at 1:41pm
I need a formula for inserting the text "Present" if the date field is blank, else insert the date value. I have the first part of formula but can't seem to get the date to pull in when the field is populated...here is what I have
if isnull({evaluations.termination_date_of_assignments})then "Present"
else({evaluations.termination_date_of_assignments})= DateValue ()

Thanks!
IP IP Logged
Amanda_K
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 3
Quote Amanda_K Replybullet Posted: 27 Jan 2010 at 2:31pm
currentdate
 
if isnull({evaluations.termination_date_of_assignments})then "Present"
else({evaluations.termination_date_of_assignments}) = currentdate
Amanda
IP IP Logged
davejwhite
Newbie
Newbie


Joined: 19 Jan 2010
Online Status: Offline
Posts: 34
Quote davejwhite Replybullet Posted: 28 Jan 2010 at 1:54am
You will have a problem with this because the two parts of an IF must return the same data type.
 
Try
if isnull({evaluations.termination_date_of_assignments}) then
    "Present"
else
    ToText({evaluations.termination_date_of_assignments}, "dd/mm/yyyy")
 
Notes:
1. If you want the expression to return the date in the field if it is not Null, you just need the field name in the Else part
2. The ToText function for Data data allows you to supply a string argument which 'lays out' the date - this one will give the date as (e.g.) 01/10/2009
3. To get help on a particular function, put it into the Build pane in the Formula Editor, click inside the Function name and press the F1 key on your keyboard. You get context-related Crystal Reports help on that Function.
 
Good luck!
IP IP Logged
Karon
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 4
Quote Karon Replybullet Posted: 28 Jan 2010 at 5:26am
This worked great, except it is pulling in the date like this MM/27/2001...missing the number of the month.

Thanks so much for the help!
IP IP Logged
Karon
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 4
Quote Karon Replybullet Posted: 28 Jan 2010 at 5:59am
I got it to work, by capitalizing the MM and small caps on the dd and yyyy....that doesnt make a whole let of sense to me...but it looks great! Again, thanks for the help!
IP IP Logged
davejwhite
Newbie
Newbie


Joined: 19 Jan 2010
Online Status: Offline
Posts: 34
Quote davejwhite Replybullet Posted: 28 Jan 2010 at 8:30am
OOps - my fault. I'm too used to Access syntax. Have a look at the Help on ToText and you'll see why!
IP IP Logged
Karon
Newbie
Newbie
Avatar

Joined: 27 Jan 2010
Location: United States
Online Status: Offline
Posts: 4
Quote Karon Replybullet Posted: 28 Jan 2010 at 9:24am
Ahh...I see mm is for minutes. Thanks for the tip on the F1 feature...I didn't know that, and that is going to be very helpful.
IP IP Logged
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