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
hkp716hkp716 

Date and DateTime confusion

Hi everyone,

 

I can retrieve any records with this query.  It is an issure with the Date format.  Is lastmodifieddate a date or datetime?  If i remove the LastModifiedDate >=:d AND LastModifiedDate <=:c filter the query works just fine.

 

 

Date d = system.Today().addDays(-3);
Date c = system.Today().addDays(-5);

//collect a list of records
//
List<Lead> setfollow = [SELECT Id, OwnerID, status FROM Lead WHERE LastModifiedDate >=:d AND LastModifiedDate <=:c AND Map_Record_Type__c = 'Contract/Direct Customer' AND IsConverted = FALSE AND status IN('Qualified', 'Prospecting')];

 

Im trying to get a list of leads that havent been modified in 4 days.

 

I already tried:

Date d = system.Today().addDays(-4) 

and bind it with the query but nothing shows up.

 

Any ideas?

 

-hkp716

sfdcfoxsfdcfox

LastModifiedDate is a DateTime (despite the moniker). Use a DateTime function instead, or use date literals:

 

LastModifiedDate >= LAST_N_DAYS:5 AND LastModifiedDate <= LAST_N_DAYS:3

See the Web Services Developer's Guide section on Date Literals for more details.

hkp716hkp716

Tried using literals, couldn't get them to fit my needs..... i changed the query around and took out the "=" operator.  Workk for now.

 

I appreciate the help sfdcfox.

 

-hkp716