I have a data source that is in UTC (Coordinated Universal Time) and iam in the CET (Central European Time) timezone. So a need too change this time to the relevant timezone so that the data can be understood.
For example if some one is adding a post to the database in 1300 CET, the database says 1200 UTC and when the report is created it says that the post was created 1200 and the reader thinks that this is in CET.
So you can do it litke this:
local datetimevar x:=*Some Date*; DateTime (YEAR(x), Month(x), day(x), hour(x)+1, minute(x), second(x))
But there is a problem with this approach and that is when is summer time we have Daylight savings so CET (Central European Time) becomes CEST (Central European Summer Time). So CET is +1h to UTC
So a better way to do this is to do it like this:
local datetimevar x:=*Some Date*; ShiftDateTime (DateTime (YEAR(x), Month(x), day(x), hour(x), minute(x), second(x)), "CET,-60,CEST,0", "")
Explaining the syntax
ShiftDateTime shifts a DateTime value from one time zone to another time zone.
ShiftDateTime (inputDateTime, inputTimeZone, newTimeZone)
inputDateTime: a DateTime value to be shifted.
inputTimeZone: a “TimeZoneString” representing the time zone of the inputDateTime.
newTimeZone: a “TimeZoneString” representing the time zone to which the inputDateTime is shifted
The last empty string in my example indicates the local time zone is taken from the OS settings.
My TimeZoneString is constructed like this:
CET = String name of the standard time zone (eg Central European Time).
-60 = Offset, in minutes, of the standard time zone (CET is -1 hence -60 minutes).
CEST = String name of the DST time zone (eg Central European Summer Time).
0 = Optional DST offset from standard, defaults to one hour ahead of standard offset.