I am running an hourly batch. This batch should pick all the records of an object say abc__c whose particular field Eligible__c is set to true in past one hour. I am trying to fetch these records by having a field maintained in the object that gets updated with the time stamp when the field is set to true using workflow field update. I am using the following query in my batch apex
DateTime curTime = datetime.now(); String queryToProcess = 'select id, name from abc__c where Eligible__c = true and MarkedEligibleTime__c <= :curTime';
Here I am comparing the field MarkedEligibleTime__c (that maintains time stamp) against the current time when batch is running and if it is less than the current time then I am picking the corresponding records. After batch is processed will ensure that MarkedEligibleTime__c is reset so that it doesn't get picked in next hourly batch. Is it the right approach to do or is there a better approach to achieve this ?