ShowAll Questionssorted byDate Posted
Robert Lange 6

# I am attempting to make a formula field on the contact object. If the contact record field “Date_Passed_MD_Bar__c” is > or = 5, I want the formula to write text that says “Greater than 5 years”.

This is the formula I wrote, but it is not working:
IF TODAY()-(Date_Passed_MD_Bar__c)>=5 "Greater than 5 years"

Best Answer chosen by Robert Lange 6
Sarvani
Hi Robert,

The formula you have used gives number of days between the today and Date_Passed_MD_Bar__c not actual years between.
Try below formula:
```if(
(ABS(YEAR(TODAY())-YEAR(Date_Passed_MD_Bar__c))) + (DAY(Date_Passed_MD_Bar__c)/DAY(Date_Passed_MD_Bar__c))>5,'Greater than 5 years',''
)```
Reference:
https://developer.salesforce.com/forums/?id=9060G0000005jMrQAI

Hope this helps! Please mark as solved if it does

Thanks

Sarvani
Hi Robert,

The formula you have used gives number of days between the today and Date_Passed_MD_Bar__c not actual years between.
Try below formula:
```if(
(ABS(YEAR(TODAY())-YEAR(Date_Passed_MD_Bar__c))) + (DAY(Date_Passed_MD_Bar__c)/DAY(Date_Passed_MD_Bar__c))>5,'Greater than 5 years',''
)```
Reference:
https://developer.salesforce.com/forums/?id=9060G0000005jMrQAI

Hope this helps! Please mark as solved if it does

Thanks
This was selected as the best answer
Robert Lange 6
Sarvani,