Skip to main content

Legacy Messaging Functions

The AMPS distribution includes a library of legacy messaging compatibility functions. These functions are intended to ease migration to AMPS from legacy messaging systems that provide similar functions.

In this release, the legacy messaging functions provide functions to make it easy to work with date and time.

These functions are not loaded into AMPS by default. To enable them, you must load the legacy messaging compatibility module by adding a directive to the AMPS configuration file. Once the module is loaded, the functions become available. No further configuration is required.

For example, adding the following configuration item to the Modules block of the AMPS configuration file loads the legacy messaging compatibility functions.

<AMPSConfig>
...

<Modules>
...

<Module>
<Name>compatibility-functions-module</Name>
<Library>libamps_udf_legacy_compatibility.so</Library>
</Module>

</Modules>

</AMPSConfig>
TIMEZONEOFFSET

TIMEZONEOFFSET


TIMEZONEOFFSET()

Returns a long that contains the current timezone offset represented in seconds East of UTC.

Parameters

None.

Returns

The current timezone offset in seconds East of UTC.

Example

Calling TIMEZONEOFFSET in the PDT timezone returns -25200 (-7 hours in seconds).

YEAR

YEAR


YEAR(timestamp)

Returns the year for the provided timestamp in YYYY format. The year is calculated in the UTC timezone.

Parameters

  • timestamp: UNIX timestamp.

Returns

The year represented by timestamp when interpreted in UTC.

Example

Calling YEAR on a timestamp that represents January 25, 2010 at 10:04 AM in UTC returns 2010.

MONTH

MONTH


MONTH(timestamp)

Returns the month (1-12) for the provided timestamp. The month is calculated in the UTC timezone.

Parameters

  • timestamp: UNIX timestamp.

Returns

The month represented by timestamp when interpreted in UTC.

Example

Calling MONTH on a timestamp that represents January 25, 2010 at 10:04 AM in UTC returns 1.

DAY

DAY


DAY(timestamp)

Returns the day (1-31) for the provided timestamp. The day is calculated in the UTC timezone.

Parameters

  • timestamp: UNIX timestamp.

Returns

The day represented by timestamp when interpreted in UTC.

Example

Calling DAY on a timestamp that represents January 25, 2010 at 10:04 AM in UTC returns 25.

DATE_UTC

DATE_UTC


DATE_UTC(timestamp)

Returns the UNIX timestamp for the beginning of the provided local calendar day (00:00:00) in UTC (i.e. the date is calculated in local time then the time is adjusted for when that day started in UTC).

Parameters

  • timestamp: UNIX timestamp.

Returns

The UNIX timestamp for the UTC start of the provided local calendar date.

Example

Calling DATE_UTC in the PDT timezone on a timestamp that represents May 21, 2026 at 22:00:00 PDT will return a UNIX timestamp representing May 21, 2026 at 00:00:00 UTC even though the date for the given timestamp in UTC is May 22, 2026.

DATE

DATE


DATE(timestamp)

Returns the UNIX timestamp for the beginning of the provided day (00:00:00) in the local timezone.

Parameters

  • timestamp: UNIX timestamp.

Returns

The UNIX timestamp for the start of the provided day in local time.

Example

Calling DATE in the PDT timezone on a timestamp that represents May 21, 2026 at 22:00:00 PDT will return a UNIX timestamp representing May 21, 2026 at 00:00:00 PDT.

TODAY_UTC

TODAY_UTC


TODAY_UTC()

Returns the UNIX timestamp for the beginning of the current local calendar day (00:00:00) in UTC (i.e. the date is calculated in local time then the time is adjusted for when that day started in UTC).

Parameters

None.

Returns

The UNIX timestamp for the UTC start of the local calendar date.

Example

Calling TODAY_UTC in the PDT timezone on May 21, 2026 at 22:00:00 PDT will return a UNIX timestamp representing May 21, 2026 at 00:00:00 UTC even though current date in UTC is May 22, 2026.

TODAY

TODAY


TODAY()

Returns the UNIX timestamp for the beginning of the current day (00:00:00) in the local timezone.

Parameters

None.

Returns

The UNIX timestamp for the start of the local day.

Example

Calling TODAY in the PDT timezone on May 21, 2026 at 22:00:00 PDT will return a UNIX timestamp representing May 21, 2026 at 00:00:00 PDT.