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

how to fiter created date as it is working in standard product filter?

Hello ,

             I have one requirement to make custom product functionality so i am making filter for that but how to check it with created date in query? createdDate only allows date time format and their standard product allows following formats i.e.


                   Valid date format 3/10/2011 or 3/10/2011 1:17 PM


so how can i do as they did? reply me fast if anyone knows ?


Thank you,

Minkesh Patel


I've found that the easiest way to query against created date is to create a local DateTime variable representing the point in time and bind that in to the query.





List<Contact> conts=[select id, Name from Contact where createddate<:dt];




I have one more suggestion, that is working for us for filtering DateTime fields.

You can make your date string in the format: YYYY-MM-DDThh:mm:ssZ

The datetime works directly in soql in this format.


Hello Bob,

                    I know that we can do it that way but i am building my SOQL query as a String and i if user enters in MM/DD/YYYY format how we will set it into the query? So i have used like MM/DD/YYYYT00:00:00Z to MM/DD/YYYYT23:59:59Z. just appended that time and checking that created date is in between of this two than we got the date ? Is It right way ?


According to the docs at:


SOQL expects the date separators to be '-', e.g.






Hello Bob,

                   yes that is true but sorry i forgot to tell you that user will enter date in that format and in controller i have written logic and replaced it with '-' sign.


Hello Bob,

                    I am planning to give certification Dev(401). So if u have any material or some document from which i can prepare for that exam.


I found the Developer Guide to be invaluable when preparing for this exam.  I spent the weekend before working through all of the examples.  It also helps to be working on the platform for a while.