You need to sign in to do that
Don't have an account?
AndreyVol
SOQL Date literal TODAY is evaluated incorrectly
I am having the following problem. When I use TODAY literal in my SOQL statements comparing with ActivityDate for some reason the records where date = tomorrow are returned. Here are the details:
Code:
The statement does not return events where ActivityDate is 05/18/2007. Instead in returns events where ActivityDate is 05/19/2007.
When I filter by a Datetime field (Event.ActivityDatetime) this does not occur and correct records are returned.
For now, I just simply modified my SOQL to use YESTERDAY instead of TODAY. But I would like to know the reason for this behavior. Am I missing something here or this could be an issue?
Thank you.
Code:
Select e.ActivityDate, e.ActivityDateTime, e.Id, e.Subject from Event eToday is 05/18/2007
Where e.OwnerId = '<myId>' AND e.ActivityDate = TODAY
The statement does not return events where ActivityDate is 05/18/2007. Instead in returns events where ActivityDate is 05/19/2007.
When I filter by a Datetime field (Event.ActivityDatetime) this does not occur and correct records are returned.
For now, I just simply modified my SOQL to use YESTERDAY instead of TODAY. But I would like to know the reason for this behavior. Am I missing something here or this could be an issue?
Thank you.
~ sfdcfox ~
The problem occurs when I query Date fields (not Datetime). So, it appears that Date fields are not offset by the user settings as Datetime fields are... Instead they are returned always in GMT. To me this seems inconsistent...
Message Edited by AndreyVol on 05-24-2007 06:35 PM
Select id from lead where Lead_expiration_date__c > TODAY
In place of Today, you should use Date.Today().
So you have to filter using the below one:
ActivityDate = Date.Today()
If you find your Solution then mark this as the best answer.
Thank you!
Regards
Suraj Tripathi