You need to sign in to do that
Don't have an account?
Dave The Rave
Calculate calendar years between 2 dates
I have two fields RegFrom__c and RegUntil__c.
I would like to calculate how many calendar years there are between 2 dates WHERE:
CertRegFrom__c= 01-06-2018
CertRegUntil__c = 02-06-2023
This is a period of 5 years, but 6 calendar years, so result of the formula should be 6, the formula below returns 5.
between the dates above you have the following calendar years 2018, 2019, 2020, 2021, 2022, 2023.
If CertRegFrom = 01-01-2018 AND CertRegUntil = 31-01-2022 then the formula must equal = 5
Can anyone help me adapt this formula?
Dave
I would like to calculate how many calendar years there are between 2 dates WHERE:
CertRegFrom__c= 01-06-2018
CertRegUntil__c = 02-06-2023
This is a period of 5 years, but 6 calendar years, so result of the formula should be 6, the formula below returns 5.
between the dates above you have the following calendar years 2018, 2019, 2020, 2021, 2022, 2023.
If CertRegFrom = 01-01-2018 AND CertRegUntil = 31-01-2022 then the formula must equal = 5
(CertRegUntil__c - CertRegFrom__c) /365
Can anyone help me adapt this formula?
Dave
use the below formula
(ABS(YEAR(CertRegUntil__c)-YEAR(CertRegFrom__c))) + (DAY(CertRegUntil__c)/DAY(CertRegUntil__c))
I hope this is helpful
"Appreciate your feedback"
All Answers
CertRegFrom__c.daysBetween(CertRegUntil__c)/365;
Thanks,
Rohit B
See image below, error is Error: Unknown function CertRegFrom__c.daysBetween. Check spelling.
What is the issue here? does the above formula did not calculate the value correctly?
"Appreciate your feedback"
use the below formula
(ABS(YEAR(CertRegUntil__c)-YEAR(CertRegFrom__c))) + (DAY(CertRegUntil__c)/DAY(CertRegUntil__c))
I hope this is helpful
"Appreciate your feedback"
Chandra@Atlanta
This accepted answer doesn't seem right: (ABS(YEAR(CertRegUntil__c)-YEAR(CertRegFrom__c))) + (DAY(CertRegUntil__c)/DAY(CertRegUntil__c))
The (DAY(CertRegUntil__c)/DAY(CertRegUntil__c)) expression at the end is just 1. Wouldn't it be easier to just add 1 like this?
(ABS(YEAR(CertRegUntil__c)-YEAR(CertRegFrom__c))) + 1