Print Page | Close Window

Checking for NULL date

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=81
Printed Date: 27 Mar 2024 at 11:17pm


Topic: Checking for NULL date
Posted By: emoreau
Subject: Checking for NULL date
Date Posted: 29 Dec 2006 at 8:55am
I have a formula (crystal syntax) in a report. In this formula, I have to check the mont of a date field but this date sometime contains a NULL value.
 
If I remove the comment from the line containing "month({UnitValueCurrent.Date})", I receive an error saying that a date value must be provided.
 
Any ideas on how I can handle this?
 
My current formula:
if (not {?ShowSRUnitValues}) then //or IsNull({UnitValueCurrent.Date}) then
    0
else
    if mailto:%7b@ReturnCDN - {@ReturnCDN } > 0 then
        {UnitValueCurrent.ClassA} * ( 1 + ( mailto:%7b@ReturnCDN - {@ReturnCDN } / 100 * .8) )
    else
//        if not ( month({UnitValueCurrent.Date}) = 12 ) then
//            {UnitValueCurrent.ClassA}
//        else
            {UnitValueCurrent.ClassA} * ( 1 - ( mailto:%7b@ReturnCDN - {@ReturnCDN } / 100 * .8) )


-------------
HTH

Eric Moreau
MCSD, Visual Developer - Visual Basic MVP



Replies:
Posted By: hilfy
Date Posted: 02 Jan 2007 at 9:22am
You could break down your If statement further to something like this:
if (not {?ShowSRUnitValues}) then 
    0
else if IsNull({UnitValueCurrent.Date}) then
    0
else
    if mailto:%7b@ReturnCDN - {@ReturnCDN } > 0 then
        {UnitValueCurrent.ClassA} * ( 1 + ( mailto:%7b@ReturnCDN - {@ReturnCDN } / 100 * .8) )
    else
        if not ( month({UnitValueCurrent.Date}) = 12 ) then
            {UnitValueCurrent.ClassA}
        else
            {UnitValueCurrent.ClassA} * ( 1 - ( mailto:%7b@ReturnCDN - {@ReturnCDN } / 100 * .8) )
 
I've found that sometimes Crystal gets confused with 'or' in the condition.  Sometimes you can resolve the problem by switching the order of what's being evaluated in the or statement and sometimes you just have to find a different way to handle it.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics



Print Page | Close Window