You need to sign in to do that
Don't have an account?
Tinku
syntax to know the day of the week
What is the syntax to know the Day of the week.
And also to subtract one date field with Today's date.
the requirement is like this:
If(Today=Friday)
{
if( (account.createdDate - Today) > 21 || (Today - account.CreatedDate) >21 )
{
Create case;
}
}
I need the help with the Blue Link part.
This will get you the day of the week, based on a date (where TimeDate__c is your date field):
CASE(MOD( TimeDate__c - DATE(1900, 1, 6), 7), 0, "Saturday", 1, "Sunday", 2, "Monday", 3, "Tuesday", 4, "Wednesday", 5, "Thursday", 6, "Friday","")
Dates subtract just like any other field, something like: Today() - TimeDate__c
this is to write inside the apex trigger code.
When i wrote Today() - account.CreatedDate inside the apex trigger.
It gives me this error:
Compile Error: Method does not exist or incorrect signature: TODAY()
Try System.today().
Failing that you can use Datetime dt = System.now(); to return a datetime object, but I'm not entirely sure if you can subtract from that directly. Check out the Apex Code documentation (http://www.salesforce.com/us/developer/docs/apexcode/index.htm) and search for "datetime" for more information on the methods available.
You can get the day of the week from a DateTime field by executing the format method with the appropriate pattern,
E.g. to get the day of the week as Mon, Tue etc
Bob.
What is 'EEE' in your syntax? Do i have to write Monday instead of EEE? or is it the syntax?
How to subtract one date from another?
EEE is the replacement pattern for day of the week. If you use the code today (Friday) you will get "Fri" in the string. The replacement patterns are the same as those in the Java SimpleDateFormat class, information on which can be found at:
http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
Thank you.