Question:
The following article presents CRM SOQL Query Examples in Relation to Start Date Times and End Date Times, and how they are interpreted.
Answer:
The Salesforce (SFDC) platform uses the following date format:
'Date' field acceptable formats
-
YYYY-MM-DD
-
YYYY-MM-DD hh:mm:ss
-
YYYY-MM-DD hh:mm:ss
-
YYYY-MM-DDThh:mm:ssZ
-
YYYY-MM-DDThh:mm:ss.sssZ
'Date Time' field acceptable formats
-
YYYY-MM-DD hh:mm:ss
-
YYYY-MM-DDThh:mm:ssZ
-
YYYY-MM-DDThh:mm:ss.sssZ
'Time' field acceptable formats
-
hh:mm:ss.sssZ (For example, 07:00:00.000Z)
The first query example shows how to get the accurate start date times and end date times:
select id from Sent_Email_vod__c where CreatedDate > 2022-05-25T00:00:00.000+02:00 and CreatedDate < 2022-05-27T23:59:59.999+02:00
The second example queries records between two specific dates:
select id from Sent_Email_vod__c where CreatedDate > 2022-05-25T18:00:00.000+02:00 and CreatedDate < 2022-05-27T10:30:59.999+02:00
The +02:00 is considered an offset, which determines the timezone. +02:00 is CEST in these query cases. Any Salesforce DateTime type of fields of any Veeva CRM objects fall into this category.
Related Documentation:
Salesforce Help Documentation: