Create a gist now

Instantly share code, notes, and snippets.

Salesforce: Add an Opportunity formula field for "Days since release"
# Salesforce Custom Formula for "Days Since Release" based on Opportunity CloseDate
IF(
/* 2012 - Win 8, Mac 10 */
AND(
CloseDate >= DATE(2012,11,6),
CloseDate < DATE(2014,3,4)
),
CloseDate - DATE(2012,11,6),
IF(
/* 2014 - Win 9, Mac 11 */
AND(
CloseDate >= DATE(2014,3,4),
CloseDate < DATE(2015,3,17)
),
CloseDate - DATE(2014,3,4),
IF(
/* 2015 - Win 10, Mac 12 */
AND(
CloseDate >= DATE(2015,3,17),
CloseDate < DATE(2016,3,1)
),
CloseDate - DATE(2015,3,17),
IF(
/* 2016 - Win 11, Mac 13 */
AND(
CloseDate >= DATE(2016,3,1),
CloseDate < DATE(2017,3,7)
),
CloseDate - DATE(2016,3,1),
IF(
/* 2017 - Win 12, Mac 14 */
AND(
CloseDate >= DATE(2017,3,7),
CloseDate < DATE(2018,3,1)
),
CloseDate - DATE(2017,3,7),
10000
)
)
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment