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
varma uvarma u 

SOQL query

how to write soql query to get the records from account object which are not modified since one year?
gautam_singhgautam_singh
Hi, 

If you have records in Account object which are not modified since one year, You can query 

SELECT Id , Name , LastModifiedDate from Account where LastModifiedDate < 2014-01-01T00:00:00.000+0000 limit 10


Important :

If this is what you where looking for then please mark it as a solution for others benefits.

Thank You
Vatsal KothariVatsal Kothari
Hi,

Use below query:

SELECT Id,Name,LastModifiedDate FROM Account where LastModifiedDate = THIS_YEAR
If this solves your problem, kindly mark it as the best answer.

Thanks,
Vatsal
sfdc Beginnersfdc Beginner
Hi varma,


Use Below Query:
 

SELECT Id,Name,LastModifiedDate FROM Account WHERE LastModifiedDate < LAST_N_DAYS:366


If this solves your problem, Kindly mark it as the  best answer.




Thanks,
SFDC Beginner
varma uvarma u
I want to match with current date and get the records.
sfdc Beginnersfdc Beginner
Hi Varma,

This Query works for current Date only

SELECT Id,Name,LastModifiedDate FROM Account WHERE LastModifiedDate < LAST_N_DAYS:366

If this solves your problem, Kindly mark it as the  best answer.

Thanks,
SFDC Beginner.

Bhawani SharmaBhawani Sharma
Select Id from Account where LastModifiedDate < THIS_YEAR
or
Select Id from Account where Calender_Year(LastModifiedDate) < THIS_YEAR

See these links:
http://www.salesforce.com/us/developer/docs/officetoolkit/Content/sforce_api_calls_soql_select_dateformats.htm
http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select_date_functions.htm
Kiran  KurellaKiran Kurella
You can also try the following soql, which I believe will handle the leap year as well.

SELECT Id,Name,LastModifiedDate FROM Account WHERE LastModifiedDate < :system.today().addYears(-1)