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
V AnandV Anand 

How to compare datetime fields in trigger?

 

Field that records the Date/Time of the last received lead. Now  I want to compare  current date  with previous date of same field.

 

Could you please any one write coding for above....... 

Bhup@esplBhup@espl

Campare your dateTime field with "isSameDay".

 

datetime myDate = datetime.now();

datetime previousDate = datetime.newInstance(2008, 1, 30);

boolean dueNow = myDate.isSameDay(dueDate);

Bhup@esplBhup@espl

I missed to change variable name

 

datetime myDate = datetime.now();

datetime previousDate = datetime.newInstance(2008, 1, 30);

boolean dueNow = myDate.isSameDay(previousDate );

_Prasu__Prasu_

In after insert trigger you can get old values and new values array for the records which have fired the trigger. you can compare the old values and new values and do the needful.