DateTime UDFs

DateTime UDFs in Trino

This section provides a list of DateTime UDFs for the protect, unprotect, and reprotect operations.

Caution: There are inconsistencies observed when Trino is used to fetch and store date values from HDFS, where data was stored using Hive. It is recommended to verify if the correct date and datetime values are retrieved when the data is fetched from or stored in HDFS without using the Trino UDFs. If the data consistency is maintained, only then proceed to the Trino Date or DateTime UDFs.

ptyProtectDateTime()

This UDF protects the TIMESTAMP value. The DateTime UDFs in Trino support an input precision of 12 digits or picoseconds.

Signature:

ptyProtectDateTime(timestamp(p) input, varchar dataElement)

Parameters:

NameTypeDescription
inputTimestamp(p)Specifies the data in the Timestamp(p) format, which needs to be protected where p is the digits of precision for the fraction of seconds.
dataElementVarCharSpecifies the name of the data element to protect the data.

Returns:
This UDF returns the protected Timestamp(p) value.

Example:

select ptyProtectDateTime(cast('2018-10-10 20:35:17.123' as TIMESTAMP(3)), 'DateTime_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyProtectDateTime()DateTimeNoNoYesNoYes

ptyUnprotectDateTime()

This UDF unprotects the protected Timestamp value.

Signature:

ptyUnprotectDateTime(timestamp(p) input, varchar dataElement)

Parameters:

NameTypeDescription
inputTimestamp(p)Specifies the data in the Timestamp(p) format, which needs to be unprotected where p is the digits of precision for the fraction of seconds.
dataElementVarCharSpecifies the name of the data element to unprotect the data.

Returns:
This UDF returns the unprotected Timestamp(p) value.

Example:

select ptyUnprotectDateTime(ptyProtectDateTime(cast('2018-10-10 03:04:05.123' as TIMESTAMP(3)), 'DateTime_DE'), 'DateTime_DE');

Supported Protection Methods:

Function NameTokenizationEncryptionFPENo EncryptionMaskingMonitoring
ptyUnprotectDateTime()DateTimeNoNoYesNoYes

ptyReprotect() - DateTime


Last modified : December 18, 2025