You need to sign in to do that
Don't have an account?
Karthik j
soql query not returning result with dynamic variable
Hi all,
I am trying to query all the tasks which are last modified today.
List<Task> taskList= [Select Id,status,LastModifiedDate from Task where LastModifiedDate=TODAY];
the above query is returning the result, but my problem is when I tried to use the variable as shown below instead of TODAY I am not getting any result.
Date todayDate = date.today();
List<Task> taskList= [Select Id,status,LastModifiedDate from Task where LastModifiedDate=:todayDate];
you might say todayDate is the variable with date type and the last modified date is the DateTime field. so it will not return any result, but why does it work in the first place with TODAY?
I am trying to query all the tasks which are last modified today.
List<Task> taskList= [Select Id,status,LastModifiedDate from Task where LastModifiedDate=TODAY];
the above query is returning the result, but my problem is when I tried to use the variable as shown below instead of TODAY I am not getting any result.
Date todayDate = date.today();
List<Task> taskList= [Select Id,status,LastModifiedDate from Task where LastModifiedDate=:todayDate];
you might say todayDate is the variable with date type and the last modified date is the DateTime field. so it will not return any result, but why does it work in the first place with TODAY?
date.today(); is returning a fixed date with time as 00:00:00 that's why it is matching with a particular date and time record. Please debug in the anonymous block but in the case of TODAY, it is returning all the records of today's date.
Kindly mark as best answer if it helps
Thanks
Shubham Jain