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
santhosh konathala 8santhosh konathala 8 

How to fetch created records in past one hour only

Vijay NagarathinamVijay Nagarathinam
Hi Santhosh,

You have to write following SOQL query for display last updated record within 1hour.
 
Select a.Id From Account a Where a.LastModifiedDate = TODAY AND HOUR_IN_DAY(a.LastModifiedDate) > 1

Let me know if you need any help regarding this,

Thanks,
Vijay
 
sandeep sankhlasandeep sankhla
Hi ,

You can use datetime.now().addHours(-1); this will give you eact tiem of last 1h...then in query you can just add if created date is greater than equal to this time. then it will give you the results those are created in last one hour.

Thanks
Amit Chaudhary 8Amit Chaudhary 8
You need to pass date and time like below
 
SELECT id,name  FROM Account where CreatedDate  = 2012-11-06T06:46:56.000Z
In below query just past last one hr date and time.
SELECT id,name  FROM Account where CreatedDate  = 2012-11-06T06:46:56.000Z

Let us know if this will help you

Thanks
Amit Chaudhary