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
Jonathan Wolff 7Jonathan Wolff 7 

Apex code to show tomorrows day and day after tomorrow

Hi, I build an Component and Controller to show the tasks of specific days. I tried it with the code below but it doesn't display the tasks of tomorrow (loadTasks3) and the day after tomorrow (loadTasks4)
Could you help me with this issue

Greetings 
Jonathan


public with sharing class TaskController {
  
    @AuraEnabled
  public static List<Task> loadTasks(Id recordId){
      string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate< TODAY 
           AND OwnerId=:userId AND Status !='Completed' ];
  }
    @AuraEnabled
  public static List<Task> loadTasks2(Id recordId){
      string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= TODAY 
           AND ActivityDate  < Next_N_Days:1 AND OwnerId=:userId ];
  }
    @AuraEnabled
  public static List<Task> loadTasks3(Id recordId){
      string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:1 
           AND ActivityDate  < Next_N_Days:2 AND OwnerId=:userId ];
  }
    @AuraEnabled
  public static List<Task> loadTasks4(Id recordId){
      string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:2 
           AND ActivityDate  < Next_N_Days:3 AND OwnerId=:userId ];
  }
  @AuraEnabled
  public static Task saveTask(Task task){
    upsert task;
    return task;
   }
}
Malika Pathak 9Malika Pathak 9
Hi Jonathan Wolff 7
find the below solution
 
@AuraEnabled
  public static List<Task> loadTasks3(Id recordId){
      string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:1 
           AND ActivityDate = TOMORROW AND OwnerId=:userId ];
  }

@AuraEnabled
  public static List<Task> loadTasks4(Id recordId){
      string userId = UserInfo.getUserId();
    return[SELECT Subject, ActivityDate FROM Task WHERE WhatId=:recordId And ActivityDate>= Next_N_Days:2 
           AND ActivityDate  = Next_N_Days:3 AND OwnerId=:userId ];
  }



Please mark it as the best answer if it helps you to fix the issue.

Thank you