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
jwoodall1jwoodall1 

Query dates using remote objects

I am having issues with using the remote objects retrieve method to filter an object using dates.  I can't figure out what format the remote objects method wants for the date.  It looks like it is using SOQL in the error message and I can get SOQL to work on this field by using the date formatted as 2015-09-23.  
 
var d = new Date();
d = d.format('yyyy-mm-dd');
coupon.retrieve({where:{Start_Date__c:{lte:d}}}, function(err,c) {
           console.log(err);
});
Error: Error occurred while performing RETRIEVE operation on sobject: Coupon__c with data: {where={Start_Date__c={lte=2015-09-23}}} (INVALID_FIELD: 
start_date__c FROM Coupon__c WHERE Start_Date__c <= '2015-09-23' LIMIT
                                   ^
ERROR at Row:1:Column:89
value of filter criterion for field 'Start_Date__c' must be of type date and should not be enclosed in quotes)


It looks like the remote call is putting the single quotes in ('), but I don't have it in my call.
 
Daniel DelgadoDaniel Delgado

var d = new Date('2016-02-23');
coupon.retrieve({where:{Start_Date__c:{lte:d}}}, function(err,c) {
           console.log(err);
});
You have to pass the Date into where clause.