Monday 2 May 2011

Date Time filter in Where Clause of Soql Query


"What if all our events in life are stored in database and we can query through the records to know about a specific day's events" -By UNKNOWN

 At times while checking for records in Force.com explorer(or any other tool like brain engine etc) we need to give some specific date time value(as filter) in the where clause of SOQL Query.


Apart from the date literals like Today,Yesterday etc we can give specific date time value. For Example 
26-April-2011 can be given as 2011-04-26T00:00:00Z


Including this in SOQL would look like:


select id,createddate from account where createddate= 2011-04-26T00:00:00Z


Following is the link where all date literals are listed out::
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_dateformats.htm




Happy Coding!! :)
Cheers





No comments:

Post a Comment