SOQL Converting Time Zones in Date Functions

SOQL queries returns dateTime field values as Coordinated Universal Time (UTC) values. You can use convertTimezone() in a date function to convert dateTime fields to the user’s time zone.

Example 1:

SELECT DAY_ONLY(convertTimezone(CreatedDate)), SUM(Amount) FROM Opportunity GROUP BY DAY_ONLY(convertTimezone(CreatedDate))

Example 2:

SELECT Id, WhatId, Subject, CreatedDate From Task Where DAY_ONLY(convertTimezone(CreatedDate)) = TODAY

Note: You cannot use convertTimezone() without date function. The following query doesn’t work because there is no date function.

SELECT convertTimezone(CreatedDate) FROM Account