The below query doesn't return any results
select Phone__c from Application__c where Orientation_Date__c < NEXT_N_DAYS:8 and Orientation_Date__c > NEXT_N_DAYS:1
But the next query returns 2 records with Orientation_Date__c
2017-07-27
and 2017-07-28
select Phone__c from Application__c where Orientation_Date__c > NEXT_N_DAYS:1
Today is 2017-07-25
so these 2 records should meet the criteria for the first query right? Why aren't they being returned?
Best Answer
Take a look at the documentation on
Date Literals
Since the range starts from midnight today, using
< NEXT_N_DAYS:n
is equivalent to< TODAY
.Unfortunately, unlike
N_DAYS_AGO:n
, there does not appear to be any sort ofN_DAYS_FROM_NOW:n
literal, so I'm not sure if there is a workaround in pure SOQL. Your best bet might be to create a formula forDays_From_Now__c
and filter on that instead.