+1 vote
20 views
by (163k points)

I have a schedule apex job that runs everyday in the morning at 2 AM, where I am trying to gather opportunities where custom date Reoffer_Date__c as today.

List opportunitiesList = [
        SELECT Id, Name, Employee_Contact__c, RecordTypeId, Employee_Contact__r.Gross_Income__c
        FROM Opportunity
        WHERE Reoffer_Date__c = System.TODAY()
];

1 Answer

+1 vote
by (163k points)
 
Best answer

As already proposed in the comments section, please tak a look at date literals like TODAY:
Date Formats and Date Literals

In terms of day(), it returns the day-of-month component of a Date (documentation). So if you want to have a full date, it's not the way to go.

As for the today, it returns current date (honoring user's time zone) indeed. It would be best for you to just review existing methods for System Class.

Welcome to Memory Exceeded, where you can ask questions and receive answers from other members of the community.
...