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
sfunstonsfunston 

Date Query Failing

I am having a problem with the following query, but the query below works.  I am not sure what the problem is here as I am certain that the date value I am using is properly constrcted.

SELECT
   mc.CreatedById, mc.CreatedDate, mc.CurrencyIsoCode, mc.Id, mc.LastModifiedById, mc.LastModifiedDate, mc.Name, mc.Opportunity__c,
   mc.SystemModstamp, o.Name, o.AcceptStatus__c, o.AccountId, Opportunity__r.CloseDate
FROM
   Manager_Commit_v2__c  mc, mc.Opportunity__r o WHERE o.CloseDate > 2007-01-01T05:00:00Z


Here is the error info:
An error has occurred: {faultcode:'sf:INVALID_FIELD', faultstring:'INVALID_FIELD: value of filter criterion for field 'CloseDate' must be of type date and should not be enclosed in quotes', detail:{fault:{exceptionCode:'INVALID_FIELD', exceptionMessage:'value of filter criterion for field 'CloseDate' must be of type date and should not be enclosed in quotes', row:'1', column:'274', }, }, }

Here is the working query.
SELECT
   mc.CreatedById, mc.CreatedDate, mc.CurrencyIsoCode, mc.Id, mc.LastModifiedById, mc.LastModifiedDate, mc.Name, mc.Opportunity__c,
   mc.SystemModstamp, o.Name, o.AcceptStatus__c, o.AccountId, Opportunity__r.CloseDate
FROM
   Manager_Commit_v2__c  mc, mc.Opportunity__r o WHERE o.CloseDate > TODAY


Thanks
sfunstonsfunston
Thanks to anyone that had time to look at this, but I realized that the field I was using in the where clause CloseDate is a Date type not DateTime.   So I had to change the value to 2007-03-31.


SuperfellSuperfell
You have where o.CloseDate > 2007-01-01T05:00:00Z you are comparing a date field (CloseDate) against a dateTimve value, for the 8.0 api you have to specify a date only value to compare against, e.g. where o.CloseDate > 2007-01-01
sfunstonsfunston
Thanks Simon.  I appreciate your time and help!
sfdc1.3890582999007844E12sfdc1.3890582999007844E12
Thanks Simon. @sfunston

For anyone tryng the same thing and banging your head like I did for a few hours. 

I was trying to use a date field as a dynamic filter for the user. how I finally did it was

CreatedDate: {
                        gt: new Date(document.getElementById("createdate").value)

obviously you can use a variable but this is where i felt like I hit paydirt.