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
Darla.ax69Darla.ax69 

Querying accounts not modified since creation

Hello,

I'm trying to count how many accounts haven't been modified since they were created. My plan was to run a query with a batch size of 1 and look at the response XML to see how many results are found. (I only need the number of accounts, not the account details).

I tried to run this query:

select Id from Account where CreatedDate = LastModifiedDate

And I get a malformed query exception. (I kind of expected that, but was hoping...)

Is there any way to accomplish this without retrieving the created date and modified date for all accounts and comparing it myself?

Thanks,

=> Darla
DevAngelDevAngel

Hi Darla,

I can't think of a way to do this as you must put a constant on the right side of the logical operator.

Unfortunately, this seems like an edge case.  In other words, what would be other situations where you  would want to compare to values on the record in a query?

Darla.ax69Darla.ax69
I could imagine it coming up from time to time. Maybe you'd want to see accounts whose billing and shipping addresses were the same, or do some comparison with custom fields. We have a field for the DUNS number and will add one for the ultimate DUNS number. I could imagine wanting to find records where they were the same.