+ Start a Discussion
New_DeveloperNew_Developer 

help with query

I need a query which returns the list of records whose lastmodifieddate falls in now() minus 2 mins

 

List<Object> reclist = [Select id from Object where LastModifiedDate =???];

 

Thanks

 

Best Answer chosen by Admin (Salesforce Developers) 
Anup JadhavAnup Jadhav

I'd do something like:

 

List<Object> recList = [Select Id from Object where Object.LastModifiedDate = System.now().addMinutes(-2) ];

 

Regards,

Anup

All Answers

Anup JadhavAnup Jadhav

I'd do something like:

 

List<Object> recList = [Select Id from Object where Object.LastModifiedDate = System.now().addMinutes(-2) ];

 

Regards,

Anup

This was selected as the best answer
jmurtyjmurty

would this be the same logic for hours? days?

Anup JadhavAnup Jadhav

if it's hours, then replace addMinutes() with addDays(), and if it's years, then addMinutes() with addYears(). Put addMonths() if you want months.

 

If this resolves your query, please mark it as solved.

 

Thanks,

Anup

Anup JadhavAnup Jadhav

Is your query resolved?

 

Regards,

Anup

 

 

New_DeveloperNew_Developer

Yes, Thank You