You need to sign in to do that
Don't have an account?
Matthew Ritter 17
I tried ld.Next_Call_Date__c.date but that did not work. Any thoughts? Thanks.
date time field to date value apex
public static List<Lead> leadsThatMissed(List<Lead> leads) { List<Lead> missedLeads = new List<Lead>(); for (Lead ld : leads) { if( ld.Next_Call_Date__c == Date.today().addDays(-1)) { ld.Call_Type__c = 'Missed'; ld.Next_Call_Date__c = ld.Next_Call_Date__c.addDays(1); missedLeads.add(ld); } } return missedLeads; }In the above snippet on an Apex class, the ld.Next_Call_Date__c field is a date/time field and I need to get the date value from that field so the comparison works. Basically, I want to say If DATEVALUE(Next_Call_Date__C) == YESTERDAY then do everyhting in the code.
I tried ld.Next_Call_Date__c.date but that did not work. Any thoughts? Thanks.
You can use date() which Returns the Date component of a Datetime in the local time zone of the context user.
ld.Next_Call_Date__c.date();
If that doesnt work try to create a new date instance like below
Regards
All Answers
You can use date() which Returns the Date component of a Datetime in the local time zone of the context user.
ld.Next_Call_Date__c.date();
If that doesnt work try to create a new date instance like below
Regards