[SalesForce] Can YEAR() be used to with a DATETIME as it can with DATE [e.g. YEAR(Datetime__c)]

SFDC Documentations tells me YEAR "Returns the year component of a Datetime in the local time zone of the context user".

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_datetime.htm

When I try to use "YEAR(Datetime__c)" in a workflow criteria I recieve error…

"Incorrect parameter type for function 'YEAR()'. Expected Date,
received DateTime"

Can YEAR() be used to with a DATETIME as it can with DATE [e.g. YEAR(Datetime__c)]

Best Answer

Try using:

YEAR(DATEVALUE(Datetime__c))

You are correct, YEAR() can not be used with a DateTime object. You need to convert that DateTime object to a Date beforehand using the DATEVALUE() formula.

Related Topic