You need to sign in to do that
Don't have an account?
Stephen02
Efficient Formula for Calculating Date
Trying to determine a more efficient way to write the below formula. Basically it evaluates the current day of the week, and if Monday - Thursday (e.g. 1-4) and it's before 1PM then return Today, else return Today + 1. IF the day is Friday before 1PM then return Today, else Today + 3. If Saturday (6), return Today + 2. If Sunday (7), return today +2
IF(
OR(CM_Test_Date_Field__c = "1",CM_Test_Date_Field__c = "2",CM_Test_Date_Field__c = "3",CM_Test_Date_Field__c = "4",CM_Test_Date_Field__c = "7"),
IF(NOW() < DATETIMEVALUE(TODAY())+(19/24), TEXT(YEAR(TODAY())) + LPAD(TEXT(MONTH(TODAY())),2,"0") + LPAD(TEXT(DAY(TODAY())),2,"0"), TEXT(YEAR(TODAY()+1)) + LPAD(TEXT(MONTH(TODAY()+1)),2,"0") + LPAD(TEXT(DAY(TODAY()+1)),2,"0")),
IF(CM_Test_Date_Field__c = "5",IF(NOW() < DATETIMEVALUE(TODAY())+(19/24), TEXT(YEAR(TODAY())) + LPAD(TEXT(MONTH(TODAY())),2,"0") + LPAD(TEXT(DAY(TODAY())),2,"0"), TEXT(YEAR(TODAY()+3)) + LPAD(TEXT(MONTH(TODAY()+3)),2,"0") + LPAD(TEXT(DAY(TODAY()+3)),2,"0")),TEXT(YEAR(TODAY()+2)) + LPAD(TEXT(MONTH(TODAY()+2)),2,"0") + LPAD(TEXT(DAY(TODAY()+2)),2,"0")))
IF(
OR(CM_Test_Date_Field__c = "1",CM_Test_Date_Field__c = "2",CM_Test_Date_Field__c = "3",CM_Test_Date_Field__c = "4",CM_Test_Date_Field__c = "7"),
IF(NOW() < DATETIMEVALUE(TODAY())+(19/24), TEXT(YEAR(TODAY())) + LPAD(TEXT(MONTH(TODAY())),2,"0") + LPAD(TEXT(DAY(TODAY())),2,"0"), TEXT(YEAR(TODAY()+1)) + LPAD(TEXT(MONTH(TODAY()+1)),2,"0") + LPAD(TEXT(DAY(TODAY()+1)),2,"0")),
IF(CM_Test_Date_Field__c = "5",IF(NOW() < DATETIMEVALUE(TODAY())+(19/24), TEXT(YEAR(TODAY())) + LPAD(TEXT(MONTH(TODAY())),2,"0") + LPAD(TEXT(DAY(TODAY())),2,"0"), TEXT(YEAR(TODAY()+3)) + LPAD(TEXT(MONTH(TODAY()+3)),2,"0") + LPAD(TEXT(DAY(TODAY()+3)),2,"0")),TEXT(YEAR(TODAY()+2)) + LPAD(TEXT(MONTH(TODAY()+2)),2,"0") + LPAD(TEXT(DAY(TODAY()+2)),2,"0")))
I haven’t tested this but hopefully the syntax is 100% correct—I am sure you can see the logic though. [ PS: Is Sunday really “+2”? ]
Hope this is useful to you.
Apparently bolding inside a code snippet is fine in preview but once posted gets coverted to pseudo-HTML. Sorry about that. I was just trying to separate the two formulas.