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
Estée ChaoEstée Chao 

Need to create a formula field that determines the number of days between the end date of a contract and today. Help! Womp.

Hello all! 

I am working on the 'Use Formula Fields' module and the challenge have me stumped.  The challenge is: 

"Create a formula field that determines the number of days between the end date of a contract and today."   With the following requirements: 
Object: Contract
Formula Return Type: Number
Field Label: Days Remaining
Field Name: Days_Remaining
Field Level Security: Visible and Read-Only for all profiles
Add the field to the standard Contract Layout page layout
The formula should return the number of days between the contract end date and today
The resulting API name for the field should be Days_Remaining__c

I have been consistently getting the error: 

"There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Account number must be 8 characters long.: []" 

Help would be much appreciated fellow developer wizards!  Thanks!!


 
Best Answer chosen by Estée Chao
Steven NsubugaSteven Nsubuga
Use 
EndDate - TODAY()

All Answers

Steven NsubugaSteven Nsubuga
You have a validation rule that only accepts Accounts with a minimum of 8 characters in its Account Number field. Deactivate that validation rule. 
@@@we@@@@@@we@@@
TODAY()-Contract EndDate
Please mark best answer
 
@@@we@@@@@@we@@@
Datatype = Formula 
Result = Number 
Formula =  TheDateField__c - TODAY() 
Estée ChaoEstée Chao
Steven - that worked, thanks for that!  I am still getting a error saying:

The 'Days_Remaining__c' formula field did not return the correct number of days between the contract end date and today.
Steven NsubugaSteven Nsubuga
Use 
EndDate - TODAY()
This was selected as the best answer
Estée ChaoEstée Chao
Thank you!!!
Steven NsubugaSteven Nsubuga
My pleasure!! Please choose a Best Answer to close/resolve the question.
Ajit KabadiAjit Kabadi
EndDate - TODAY() works!!!! but you don't see the endDate until you select contract begin date ,that is the trick
Halyson OliveiraHalyson Oliveira
TheDateField__c - TODAY() 
Ajit KabadiAjit Kabadi
Please remove the validation if you have kept on the field.Delete the validation that you have added as a part of prior challenge..on the field account
Lukesh KarmoreLukesh Karmore
Same question but my error is
User-added image