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
Neel88Neel88 

SOQL query comparing 2 date fields with fixed variable date

I am trying to do this

Date1 = 2017-12-31;
Select sum(monthlyfees__c) from customobject__c where id='12345678' and first_month__c <= date1 and last_month__c <=date1;

I get no results

But i get results for 
Select sum(monthlyfees__c) from customobject__c where id='12345678' and first_month__c <= date1;

Idea is to loop and change date1 with differnt values and get the final total for multiple soql queries in a VF page. 
Please advice.
Thanks