function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lewis BlauLewis Blau 

Get records in SOQL created 10 mins ago

Is there a way in a soql statement on an sObjectQuery to get records created at least 10 mins ago.
Example sObjectQuery= "Select Id from Contact where credateddate < now - 10 minutes"
mritzimritzi
public class SampleClass{
    public void methodName(){
        Datetime dt = System.now();
        // adding minutes in negative, effectively subtracts 10 mins
        dt = dt.addMinutes(-10);
        List<Contact> cList = [Select id From Contact where CreatedDate<=:dt];
    }
}


Mark it as Best Answer, if it helps.
nagendra 6989nagendra 6989
HI Lewis,

Check with the above code and let me know if it was useful

List<Contact> oppList = [select name from Contact where SystemModstamp >
:Datetime.now().addMinutes(-10)];
nagendra 6989nagendra 6989
HI Lewis,

Check with the above code and let me know if it was useful

List<Contact> conList = [select name from Contact where SystemModstamp >
:Datetime.now().addMinutes(-10)];