0

I have an Object (aObject) contains datetime field, I want to get all data from aObject where datetime includes 12-29-2013 ignoring the time.

any idea ?

1
1

You have 2 options for doing this directly in the SOQL query.

If you know the date you want to use "Literally" you could use a date literal:

select id,name from aObject where datetimefield = YESTERDAY;

Or, you would have to use a range of datetime values:

enter DateTime startOfDT = DateTime.newInstance(2013,12,29,0,0,0);
DateTime endOfDT = DateTime.newInstance(2013,12,29,23,59,59);
List<Case> cases = [
    select id from Case 
    where createdDate >= :startOfDT 
    and createdDate <= :endOfDT];
1
  • If you need to convert Datetime instance to a string literal use <Datetime instance>.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss\'Z\''); Apr 25 '19 at 14:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.