Long startTime = 1112222220;
Date startDate = DateTime.newInstance(Long.valueOf(startTime)).dateGmt();
system.debug('startDate: '+startDate);
String qry = 'Select Id, Subject from Task where ActivityDate > :startDate';
system.debug('qry: '+qry.replace(':startDate', ''+startDate));
The above prints the debug as:
startDate: 1973-07-11 00:00:00
qry: Select Id, Subject from Task where ActivityDate > 1973-07-11 00:00:00
It seems to contain the time portion and I do not get any Task records as part of my query. SO as I understand, I got a Date variable and I also extracted correct Date and assigned it. Then used it in a SOQL variable appropriately, but still something is not right, I might be ignoring something small, but impactful in my understanding, so need some guidance what might be wrong here in my understanding.
If I remove the time portion from startDate variable manually, my Query returns appropriate number of Task records.
1973-07-11
??00:00:00
.String strdate = DateTime.newInstance(startTime ).format('yyyy-MM-dd');