Newer Version Available
Converting Time Zones in Date Functions
SOQL queries in a client application return 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.
For example, you could use the convertTimezone(dateTimeField) function to find the sum of the Amount values for all your opportunities for each hour of the day, where the hour is converted to the user's time zone.
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17SELECT HOUR_IN_DAY(convertTimezone(CreatedDate)), SUM(Amount)
18FROM Opportunity
19GROUP BY HOUR_IN_DAY(convertTimezone(CreatedDate))Note that you can only use convertTimezone() in a date function. The following query doesn't work because there is no date function.
1SELECT convertTimezone(CreatedDate)
2FROM Opportunity