function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BuellBuell 

Using IF function with a date formula...

Not sure what is going on here.  I have a date formula:

 

DATE(2009, 02, 02)

 

I want to make it conditional on another field.  In particular if another field is 0 then I want to display a blank date.  To accomplish this I added an IF funciton:

 

IF( Custom_Field__c = 0, '', DATE(2009, 02, 02) )

 

Salesforce then throws the error:

Incorrect parameter for function IF(). Expected Text, recieved Date.

Any thought?  If I remove the function DATE() then it says it expected text and recieved a number...

Also, if I embed the function IF() within the DATE() function, I get the same error.

Message Edited by Buell on 09-25-2009 09:48 AM
Best Answer chosen by Admin (Salesforce Developers) 
Steve :-/Steve :-/

Okay, if might have something to do with the fact that you're calling in a Formula (Roll-Up Summary) field.  

 

You might want to give this shot just for the hell of it

 

 

IF(Custom_Field__c = 0, NULL, DATE(2009,02,02))

 

 

 

All Answers

Steve :-/Steve :-/
What are the data types of the fields in your formula?
BuellBuell
The formula field itself is a DATE, the Custom_Field__c is a rollup number field.
Steve :-/Steve :-/

Okay, if might have something to do with the fact that you're calling in a Formula (Roll-Up Summary) field.  

 

You might want to give this shot just for the hell of it

 

 

IF(Custom_Field__c = 0, NULL, DATE(2009,02,02))

 

 

 

This was selected as the best answer
BuellBuell
One step closer...  it now compiles to 5008 characters.
Steve :-/Steve :-/
what other formulas have you got going on?
BuellBuell

Got it! Changed IF() to CASE() and shaved 100 characters.  Thanks for your help!

 

CASE( Custom_Field__c, 0, Null, DATE(2009,02,02) )

 

saran kumar 9saran kumar 9
can anyone tell me a solution for this ........urgent User-added image