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
ZimmerZimmer 

Conditional Statement Based on Created Date

I am writing a trigger that should only fire is the created date of the object is after a certain date say august 1, 2011.

 

I am having the hardest time with the syntax of this conditional for my if statement.

 

any help would be greatly appreciated.

 

Thanks,

Phil

Best Answer chosen by Admin (Salesforce Developers) 
ForceMantis (Amit Jain)ForceMantis (Amit Jain)

Is this what you need?

 

trigger AccountTrigger on Account (before insert, before update) 
{
    DateTime d = DateTime.newInstance(2011, 8, 1);
    List<Id> accounttoprocess = new List<id>();
    for(Account a: Trigger.New)
    {
        if(a.CreatedDate > d)
            accounttoprocess.add(a.Id);
    }
}

 

If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

 

Amit Jain