This is because of the data type of DateValue(CreatedDate) is date and you are comparing it with the text "THIS_WEEK".
follow @eduard suggestion to directly use CreatedDate instead of DateValue(CreatedDate).
Currently, there is no standard formula for Calculating the current week. An idea has been created, you can upvote it. The idea Link is in below Reference.
In the same, they have provided a custom solution to it.
it depends on the current day, and your definition of the current week(sun to sat, or mon to sun).
so you can play with this formula:
case(mod( today() - DATE(1985,6,24),7),
6, if( date_field__c - today() <5, if( date_field__c - today() >=-1, "This week", if( today() - date_field__c >=9, "previous Week", "other")), if( date_field__c - today() <11, "next week", "other")),
0, if( date_field__c - today() <6, if( date_field__c - today() >=0, "This week", if( today() - date_field__c >=6, "previous Week", "other")), if( date_field__c - today() <13, "next week", "other")),
1, if( date_field__c - today() <5, if( date_field__c - today() >=-1, "This week", if( today() - date_field__c >=9, "previous Week", "other")), if( date_field__c - today() <11, "next week", "other")),
2, if( date_field__c - today() <5, if( date_field__c - today() >=-1, "This week", if( today() - date_field__c >=9, "previous Week", "other")), if( date_field__c - today() <11, "next week", "other")),
3, if( date_field__c - today() <5, if( date_field__c - today() >=-1, "This week", if( today() - date_field__c >=9, "previous Week", "other")), if( date_field__c - today() <11, "next week", "other")),
4, if( date_field__c - today() <5, if( date_field__c - today() >=-1, "This week", if( today() - date_field__c >=9, "previous Week", "other")), if( date_field__c - today() <11, "next week", "other")),
5, if( date_field__c - today() <5, if( date_field__c - today() >=-1, "This week", if( today() - date_field__c >=9, "previous Week", "other")), if( date_field__c - today() <11, "next week", "other")),
"other")
No syntax errors in merge fields or functions. (Compiled size: 2,345 characters)
you need to adjust the numbers in the formula.
the mod function in the case function is to check what week day today is:
case(mod(today() - DATE(1985,6,24),7),
6, "Sunday",
0, "Monday",
1, "Tuesday",
2, "Wednesday",
3, "Thursday",
4, "Friday",
5, "Saturday", "")
Reference:- https://success.salesforce.com/ideaView?id=08730000000KFAU
Best Answer
Try using
to build up the full address.
Address fields are a special case in Salesforce and are a concatenation of the underlying data fields. Selecting each individually can get around errors like this.