The easiest way might be to make the following Minutes_Since_Modified__c
formula:
(NOW() - LastModifiedDate) * 24 * 60
Then to query for it:
SELECT Id FROM Account WHERE Minutes_Since_Modified__c <= 30
If you ancan use Apex
, then use a Datetime
instance.
Datetime halfHourBack = Datetime.now().addMinutes(-30);
List<MyObject__c> records = [
SELECT count() FROM MyObject__c
WHERE LastModifiedDate >= :halfHourBack
];
If not, you can query the literal value as long as you can construct it using ISO 8601. For example at 12:30 PM it would look like:
List<MyObject__c> records = [
SELECT count() FROM MyObject__c
WHERE LastModifiedDate >= 2016-08-09T12:00:00Z
];