+ Start a Discussion
Balaji B 10Balaji B 10 

search a record by date ,standard fields like CreatedDate,LastModifiedDate?

Amit Chaudhary 8Amit Chaudhary 8
You can query below query for date filter
DateTime startDT=DateTime.newInstance(2011, 7, 13, 0, 0, 0);
DateTime endDT=DateTime.newInstance(2011, 7, 14, 0, 0, 0);

String queryStr='select id, name from Account ' +
                ' where CreatedDate>=:startDT ' + 
                ' and   CreatedDate<=:endDT';

List<Account> accs=Database.query(queryStr);
http://salesforce.stackexchange.com/questions/8896/using-a-date-for-a-datetime-field-in-a-soql-query

Let us know if this will help you