First convert the date value into datetime value, because format method can't used with the Date Type.
Date orig = customPage.startDate;
DateTime dtConverted = Datetime.newInstance(orig.year(),orig.month(),orig.day(),0,0,0);
System.debug(' converted date ' + dtConverted.format('yyyy-MM-dd\'T\'h h:mm:ss\'Z\'');
String qry = 'Select id, name, CreatedDate from Account ' +
'where createddate > ' + dtConverted.format('yyyy-MM-dd\'T\'h h:mm:ss\'Z\'') + ' order by name ';
List<Account> searchResults = Database.query(qry);
The debug line has a missing ')', and the format has a blank space between the two "h"s.
ReplyDeleteThanks for the solution!