You need to sign in to do that
Don't have an account?
billkat
Forming a couple of SOQL date queries
Hi all
Excuse the basic question... I'm struggling with forming two simple queries, of these types:
Select x from y WHERE LastmodifiedDate = 2010-05-17
Select x from y WHERE LastmodifiedDate > 2010-05-10 AND LastmodifiedDate < 2010-05-19
This is to run the Data Loader in batch mode, if it matters.
Tried to muddle through the API docs - failed to find anything that clarified this.
cheers
Bill
All Answers
I think the problem is the query needs a datetime value, and thats a string with only date.
You can achieve it in two ways, doing this
myDate = Date.valueOf('2010-05-17');
Select x from y WHERE LastmodifiedDate = myDate;
or simply by giving your string the datetime format which is
yyyy-mm-ddThh:mm:ss.mseZ
in this case
Select x from y WHERE LastmodifiedDate = 2010-05-17T00:00:00.000Z.
Ignacio.
Thanks Ignacio
The first looks interesting, will try it.
The second matches on the specific time part as well, so doesn't get any records. i.e. if a record is modified at 15pm the timepart needs to be 15:00:00, kind of thing.
To get rcds on a single past day I've now got this which works but is really ugly:
WHERE (LastmodifiedDate > 2010-05-17T00:00:00Z) AND (LastmodifiedDate < 2010-05-17T23:59:59Z)
Excellent, many thanks Mark...