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

Update past dates to today's date each morning

I have an object that holds over 800,000 apartment units.  One date field is Available__c which tells us when that apartment unit is available.  If a client enters an available date as today and that unit is still available tomorrow, I want the date to automatically update tomorrow.  I don't want to run a report each morning and update the dates using the data loader.


How would I go about writing code that evaluates all dates in the Unit Object that are older than today and changing the date to today?


Best Answer chosen by Admin (Salesforce Developers) 

First I would check out this article on using Batch Apex, it will allow you to easily process large amounts of data like you want.


After that look into creating a class that implements the Scheduleable interface. This class will simply execute the batch class for you on a timed schedule.


Those articles should get you started. Let us know if you have any additional questions.