You need to sign in to do that
Don't have an account?
mark_pa
Querying the API for records modified within the last hour
Hello all,
We are trying to get the API to query our data to get records modified within the last hour. When tested, we receive empty strings. The best we have gotten to work so far is getting records modified yesterday or today.
Anyone know of a way to get records modified within the last hour?
Thanks,
Mark
If you are just using the SOQL language directly then I think the Date Literals supplied as part of the language only have granularity down to a Day level... as you have found.
If you want to hard code a specific DateTime value then you can obviously just write SOQL like:
select name from Opportunity where SystemModstamp > 2010-01-18T00:00:00Z
but that doesn't help with creating a rolling window.
So, since it seems that you're doing polling of some kind, so I presume you're doing it from some language, Apex, or through the API, or something. Either way, whatever mechanism you're using should give you a way to build Datetime values based on an offset from the current time that you can use to build your query.
If you're using Apex, I think it would be:
List<Opportunity> Opps = new List<Opportunity>([select name from Opportunity
where SystemModstamp > :Datetime.now().addMinutes(-60);
Also note: if you're doing polling via the API, you might want to look into the getUpdated and getDeleted calls... they are there to help with the polling scenario.
Best, Steve.
All Answers
If you are just using the SOQL language directly then I think the Date Literals supplied as part of the language only have granularity down to a Day level... as you have found.
If you want to hard code a specific DateTime value then you can obviously just write SOQL like:
select name from Opportunity where SystemModstamp > 2010-01-18T00:00:00Z
but that doesn't help with creating a rolling window.
So, since it seems that you're doing polling of some kind, so I presume you're doing it from some language, Apex, or through the API, or something. Either way, whatever mechanism you're using should give you a way to build Datetime values based on an offset from the current time that you can use to build your query.
If you're using Apex, I think it would be:
List<Opportunity> Opps = new List<Opportunity>([select name from Opportunity
where SystemModstamp > :Datetime.now().addMinutes(-60);
Also note: if you're doing polling via the API, you might want to look into the getUpdated and getDeleted calls... they are there to help with the polling scenario.
Best, Steve.