• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

Crystal reports null values

I created a formula field in crystal  report.
I have one smallDatetime field in the data base.It can be either null or DateTime.If it is null I am displaying the string otherwise date time should be displayed.
If isnull({Cmd.LastActiveDate})Then
"Not Active"
else ({Cmd.LastActiveDate})=({Cmd.LastActiveDate})

else part is not working.It is giving error string is required here.
If it is null I am displaying the string.How to display the date if it is not null?

Thanks.
0
KavyaVS
Asked:
KavyaVS
  • 2
  • 2
2 Solutions
 
KavyaVSAuthor Commented:
If isnull({Command.LastActivityDate})Then
"No Activity Since OpenDate"
else {Command.LastActivityDate}
I tried this also but giving the same error string is required here.
How to display the date if it is not null?

Thanks.
0
 
mlmccCommented:
A formula can only return 1 data type. Since the then returns a string so the ELSE has to return a string.

Try

If isnull({Command.LastActivityDate})Then
    "No Activity Since OpenDate"
else
    CStr({Command.LastActivityDate})

mlmcc
0
 
KavyaVSAuthor Commented:
It is displaying the date as as 4/22/2011  12:00:00AM.
I want to format the field as 4/22/2011 ,but when I clicked the format field it is not giving the date time format option.
How to format it.

Thanks.
0
 
mlmccCommented:
Try formatting in the formula.  I didn;t know the format you wanted.

If isnull({Command.LastActivityDate})Then
    "No Activity Since OpenDate"
else
    CStr({Command.LastActivityDate},'M/d/yyyy')


mlmcc
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now