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
sfdcdev.ax551sfdcdev.ax551 

How can I compare datetime with date for e.g. "where trunc(createddate)='2009-11-15'"

Hi,

 

How can I compare a datetime field with date something similar to oracle's trunc function?

 

Thanks

sfdcfoxsfdcfox

I am not aware of an existing function in SOQL that will support your query. Instead, you will need to either:

a) WHERE CreatedDate > 2009-11-15T00:00:00.000Z AND CreatedDate < 2009-11-16T00:00:00.000Z

b) WHERE CreatedDate = TODAY

c) WHERE CreatedDate__c = 2009-11-15

C assumes that you have a custom field called CreatedDate__c, which would be a formula that reads "DateValue(CreatedDate)" (without quotes), using a return type of "Date". Note that dates should not be quoted, unlike SQL.