Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.

How do I Write a SOQL query which selects all leads that are modified within 60 minutes from now 

Select all  the lead Lastmodified date within 60 minutes or last hour 

1 answer
  1. Mar 29, 2018, 10:16 PM

    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 Lead WHERE Minutes_Since_Modified__c <= 60

    OR 

     

    Datetime hourBack = Datetime.now().addMinutes(-60);

    List<Lead> records = [

    SELECT Name FROM Lead

    WHERE LastModifiedDate >= :hourBack

    ];

     
0/9000