DT_TOLOCAL: Converting Universal Coordinated Time to Local Time

How to:

Coordinated Universal Time (UTC) is the time standard commonly used around the world. To convert UTC time to a local time, a certain number of hours must be added to or subtracted from the UTC time, depending on the number of time zones between the locality and Greenwich, England (GMT).

DT_TOLOCAL converts UTC time to local time.

Converting timestamp values from different localities to a common standard time enables you to sort events into the actual event sequence.

This function requires an IANA (Internet Assigned Numbers Authority) time zone database names (expressed as 'Area/Location') as a parameter. You can find a table of IANA TZ database names on Wikipedia at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones, as shown in the following image.

If you do not know what Area and Location corresponds to your time zone, but you do know your offset from GMT, or your legacy time zone name (such as EST), scroll down in the table. There are TZ database names that correspond to these time zone identifiers, as shown in the following image.

Note: If you use a standard IANA time zone database name in the form 'Area/Location' (for example, 'America/New_York'), automatic adjustments are made for Daylight Savings Time. If you use a name that corresponds to an offset from GMT or to a legacy time zone name, it is your responsibility to account for Daylight Savings Time.

Syntax: How to Convert UTC Time to Local Time

DT_TOLOCAL(datetime, timezone)

where:

datetime

Date-time

Is a date-time expression representing UTC time, containing date and time components.

timezone

Alphanumeric

Is a character expression containing the IANA time zone name of the local time, in the form 'Area/Location' (for example, 'America/New_York').

Example: Converting UTC Time to Local Time

The following request converts the current date-time value from UTC time to local time for time zone 'America/New_York'.

TABLE FILE GGSALES
SUM DOLLARS NOPRINT
COMPUTE UTC1/HYYMDS  = DT_CURRENT_DATETIME(SECOND);
COMPUTE LOCAL1/HYYMDS = DT_TOLOCAL(UTC1, 'America/New_York');
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLE *
GRID=OFF,$
ENDSTYLE
END

The output is shown in the following image.