Date Range Filter on a Datetime Field in a Custom Object Writes Date Into SOQL

  • 1
  • Problem
  • Updated 1 year ago
  • In Progress
On 11.0.2

Typically, when I create a date range filter on a date/time field on a standard object - it sets conditions with a datetime and works as expected.

I've run into an issue trying to do the exact same thing to a date/time field on a custom object - the model registeredlist soql shows that the filter has tried to set a date as the condition, which throws a soql error.

Can you confirm that this is a bug or an intended behavior?

Error:value of filter criterion for field 'CreatedDate' must be of type dateTime and should not be enclosed in quotes"
Photo of David Lin

David Lin

  • 690 Points 500 badge 2x thumb

Posted 1 year ago

  • 1
Photo of David Lin

David Lin

  • 690 Points 500 badge 2x thumb
Sorry, to be more specific, this is happening in an aggregate model.

In the basic model, the date range filter does appropriately insert a datetime into the condition.
Photo of Gregg Baxter

Gregg Baxter

  • 3,202 Points 3k badge 2x thumb
Hi David

Can you be more specific in how you intend using the aggregate model? i.e. What are you grouping or are you trying to aggregate a value according to a date range?

In the basic model if you expose the data in a table and then add the condition to the table then you need to choose the filter type as date range which will then automatically create the date range as CreatedDate >= & CreatedDate <= which will set the auto filter to autofilter_start_CreatedDate and autofilter_end_CreatedDate.