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
Kris WeixelKris Weixel 

Error: Incorrect parameter type for operator '>'. Expected Number, Date, DateTime, received Text

I have a formula field, "Age", that caluclates the ages of our clients.  Age is set up as a text return type and has this formula:
IF(TODAY() >=Date(YEAR(TODAY()), 
MONTH(Birthdate), DAY(Birthdate)), 
TEXT(YEAR(TODAY()) - YEAR(Birthdate)), 
TEXT(YEAR(TODAY()) - YEAR(Birthdate) - 1))  

I want to create an "age range" field, so created another formula field with a return type of text, but keep getting the error:  Error: Incorrect parameter type for operator '>'. Expected Text, received Number.  Here is my formula:  

IF(age__c>"18","19+",
IF(age__c>="15","15-18",
IF(age__c>="10","10-14",
IF(age__c>="6","6-9",
IF(age__c>="3","3-5",
IF(age__c<="2","None"))))))

I get an error too if I try to change my age field to a number and try it from that way.  

Thanks for any help!
Kris
VinojVinoj
Hi Kris,

I believe you need to update the formula to take the value of age as it is text field.  You would also need to change the the text to the right of the '>' operator to be an integer rather than text.  Does something like this work for you:
 
IF(VALUE(age__c)>18,"19+",
IF(VALUE(age__c)>=15,"15-18",
IF(VALUE(age__c)>=10,"10-14",
IF(VALUE(age__c)>=6,"6-9",
IF(VALUE(age__c)>=3,"3-5",
IF(VALUE(age__c)<=2,"None"))))))


 
Kris WeixelKris Weixel
Hi Vinoj,

Thank you for your response!  I tried what you have above, but see this error now:  Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 2...  Not sure why...?

Thanks!
Kris
VinojVinoj
It looks like your last IF function is missing a parameter.  It should look like this:
IF(logical_test, value_if_true, value_if_false)
Right now you have:
IF(VALUE(age__c)<=2,"None")
If the above is true you are returning "None", but you don't specify what to return when it's false.  Even though your logic is setup to handle that case the IF function needs that third parameter, which tells it what to return if the value is false.  You can try this:
IF(VALUE(age__c)<=2,"None", "None"))))))

 
Kris WeixelKris Weixel
Ahhh....right...i missed that.  :-)    Your suggestions worked!  THANK YOU so much!
Kevin MoerbeKevin Moerbe
I started off with the (Error: Incorrect parameter type for operator '>'. Expected Number, Date, DateTime, received Text) but now I get a new error. 

​​​​​​​Can someone tell me what is being spelled incorrectly?
User-added image
Abhi bhardwajAbhi bhardwaj
We also have to check the return type of the formula like in some cases if the return type is boolean, number or text type
for example
IF(((Date_of_birth__c - TODAY() ) > 15), 'senior', 'Junior')

this will check the age and return 'Senior' or 'Junior'  as text. In your case, you just need to do something like 
 
((Date_of_birth__c - TODAY() ))