+ Start a Discussion
Ishan Singh 4Ishan Singh 4 

how to set due date to next 7 day for a task in batch class

hi, In apex you can do this.

date dt = date.today() + 7;

Hope this helps!
VinayVinay (Salesforce Developers) 
Hi Ishan,

Below is sample snippet.
global class dailyCron implements Schedulable {
    public static String CRON_EXP = '0 0 8 * * ? *'; // 8am Every Day

    global static String scheduleIt() {
        dailyCron cron = new dailyCron();
        return System.schedule('Daily Cron', CRON_EXP, cron);

    global void execute(SchedulableContext sc) {

        //Send CRB Emails
        Contact [] cons = [SELECT Id FROM Contact WHERE Last_Email__c <= LAST_N_DAYS:14];

        for(Contact con : cons){
            con.Send_Email_Reminder__c = true;  

        update cons;


Below are links for your reference.


Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Vinay Kumar