Tuesday, January 28, 2014

How you can use Datetime field as a criteria in SOQL Query

How you can use Datetime field as a criteria in SOQL Query

We cannot use Datetime as condition in Where Clause in between single Quotes.
You can do something like this ,

WHERE CreatedDate > 2005-10-08T00:00:00Z
Or, you can also use Date Literals like

WHERE CreatedDate > YESTERDAY
For more information on date formats and more literal values, check this URL.
Sample:
soql += ' and Name LIKE \''+String.escapeSingleQuotes(key1)+'%\''; - not required single quote like this.
  

No comments:

Post a Comment