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
RDSSRDSS 

Query records where lastmodifieddate is between 01-08-2017 and 01-10-2017 and Createddate should not equal to LAstmodifieddate? Is it possible through SOQ:? If not what can i do get this?

Query records where lastmodifieddate should be between 01-08-2017 and 01-10-2017 and Createddate should not equal to LAstmodifieddate? Is it possible through SOQL? If not what can i do get this?

Thanks 
R
Gokula KrishnanGokula Krishnan
Hi RDSS,

In SOQL statement, you con't check the Createddate and LastmodifiedDate in condition.

Suggestion,
you can create a Formula field in the object you need to Query.
Create a Boolean Data type formula field, make you conditions there,  
1. lastmodifieddate between 01-08-2017 and 01-10-2017 
2. Createddate  != lastmodifieddate 
If you condition satisfies, return it TRUE else FALSE.

In SOQL where condition, check the formula field value equals to TRUE.

Thanks..

If it helps you, please mark is as best answer, so it will be helpful for other developers.
Aman MalikAman Malik
Hi,

As per the below salesforce article field to field comparison in WHERE clause of SOQL
https://help.salesforce.com/articleView?id=000187460&language=en_US&type=1
Kindly let me know in case any query.

Also, mark the answer as best if this helps.

Thanks,
Aman