You need to sign in to do that
Don't have an account?
Austin Gutz
Formula field: Closed Date = LAST WEEK
I'm trying to build a formula (boolean) that's checked "TRUE" if the Close Date on the record was for LAST WEEK.
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Please do not forget to mark this thread as SOLVED and answer as the BEST ANSWER if it helps address your issue.
The complete formula for Last Week - Next Week is much more complex:
Here is the Final Implementation based on ChuankaiZhou's framework would be like below by Gunish Chawla.
According the day of week and the difference of days, you can evaluate the last/next week.
mod(today() - DATE(1985,6,24),7) => 24 June 1985 is a Monday
mod(today() - DATE(1985,6,24),7) = 0 if today is a Monday
mod(today() - DATE(1985,6,24),7) = 1 if today is a Tuesday
mod(today() - DATE(1985,6,24),7) = 2 if today is a Wednesday
case(mod(today() - DATE(1985,6,24),7),
0, "Monday",
1, "Tuesday",
2, "Wednesday",
3, "Thursday",
4, "Friday",
5, "Saturday",
6, "Sunday",
"")
For each day of week and according the difference of days ( if(ClosedDate__c - today() <=2 etc) you can calculate the next/previous or other week.
It could be interesting to simplify the formula for only "LAST WEEK".
This formula is huge and works for dates. If you have to use "DATEVALUE( )" each time for a date time, that could exceed very quickly the size limit for the compiled formula.
It is not an easy problem in fact even if the principle is quite simple.
https://success.salesforce.com/ideaView?id=08730000000KFAU
Regards
Here is what I have
The only problem I'm having is a date from Sunday - Sunday is evaluating as "true".
Example:
Today is 9/1
A close date of 8/20-8/27 is getting set as "Previous Week". For my purpose, 8/27 should not be equal to the previous week (8/21-8/27).
Just change the reference DATE(1985,6,23) = Sunday
By the way, I displace "6," at the end with more logical numbers but the first formula could be better.
(also by the way, Salesforce recommends simpler formulas if the result is true or false like above)
Just change the reference date for the first date of the week.
DATE(1985,6,24) = Monday
DATE(1985,6,23) = Sunday
... if I understood your question correctly.
Regards
Alain
If I change the reference DATE to (1985,6,23) then the week is starting on a Sunday. I want our weeks to start on Monday (1985,6,24) but that still marks Sunday-Sunday as "Previous Week".
I should see:
8/27/2017 = Other <-- Using (1985,6,24) marks this as Last Week
8/28/2017 = Last Week
8/29/2017 = Last Week
8/30/2017 = Last Week
8/31/2017 = Last Week
9/1/2017 = Last Week
9/2/2017 = Last Week
9/3/2017 = Last Week <-- Using (1985,6,23) marks this as This Week
9/4/2017 = This Week
Not sure what I'm missing here.
Hi Austin,
With your last explanations, we can change the numbers in the formula.
Today: Thuesday 9/5/2017
0) Monday: 9/4 : This Week : 0
1) Sunday : 9/3 : Last Week: -1 if the week starts on Monday (0)
2) Saturday: 9/2 : Last Week : -2
3) Friday: 9/1 : Last Week : -3
4) Thurday: 8/31 : -4
5) Wednesday 8/30 : -5
6) Thuesday 8/29 : -6
7) Monday: 8/28 : Last Week -7
8) Sunday: 8/27 : Last Week: -8
9) Saturday: 8/26 : Other -9
-1 to -8 : Last Week
-9 to -15 : Other
case(mod(today__c - DATE(1985,6,24),7),
Regards
Alain
IF( AND(Drop_Date__c > (TODAY()-( WEEKDAY( TODAY() ) +7 ) ),
Drop_Date__c <= (TODAY() - WEEKDAY( TODAY() ) )
),
TRUE,
FALSE)
Thanks! I modified that and I believe this works for THIS WEEK:
IF(
AND(
Drop_Date__c < (TODAY() + 8 - ( WEEKDAY( TODAY() ) )),
Drop_Date__c >= (TODAY() - ((WEEKDAY( TODAY() ) -1 )))
),
TRUE,
FALSE)
Return Type - Checkbox
AND
(
CloseDate >= (TODAY() - MOD(TODAY() - DATE(1900, 1, 7), 7) - 6),
CloseDate <= (TODAY() - MOD(TODAY() - DATE(1900, 1, 7), 7))
)
This formula indicates the period from last Sunday to Saturday as true.