function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan 

date method problem

trigger updateday on case_obj__c (before insert){
for(case_obj__c a :trigger.new)
{
Date dt = a.case_dt__c;
String dayOfWeek=dt.format('EEEE');
a.day__c=dayOfWeek;
}
}
I tried this code but i am gethhing this error:Error: Compile Error: Method does not exist or incorrect signature: [Date].format(String)
whats is the problem?
Best Answer chosen by Vidhyasagaran Muralidharan
Tony TannousTony Tannous
You can't directly  use the format method with date.

try this it will work 
Datetime dt = (DateTime)dt;
String dayOfWeek = dt.format('EEEE'); 

Good Luck

All Answers

kiranmutturukiranmutturu
format method in Date class will not have any Arguments... So simply dt.format();
Tony TannousTony Tannous
You can't directly  use the format method with date.

try this it will work 
Datetime dt = (DateTime)dt;
String dayOfWeek = dt.format('EEEE'); 

Good Luck
This was selected as the best answer
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
Now no error but it is not showing the day it is showing the samedate than the day.Ex:case_dt__c=03/06/2014 then day__c=03/06/2014but i want in day_c as tuesday
Vidhyasagaran MuralidharanVidhyasagaran Muralidharan
@Tony cheers it works.