Compatible with PostgreSQL, Hologres allows you to use standard PostgreSQL syntax for data development.

The following table describes the date and time functions supported by Hologres. The functions supported by Hologres are only a subset of the PostgreSQL functions. For more information about how to use these functions, see Date/Time Functions and Operators and Data Type Formatting Functions in the PostgreSQL documentation.
Function Description Example Result
to_char(timestamp, text) Converts a timestamp to a string. to_char(current_timestamp, 'HH12:MI:SS') 06:26:33
to_char(int, text) Converts an integer to a string. to_char(125, '999') 125
to_char(double precision, text) Converts a real number or a double precision number to a string. to_char(125.8::real, '999D9') 125.8
to_date(text, text) Converts a string to the DATE data type. to_date('05 Dec 2000', 'DD Mon YYYY') 2000-12-05
to_number(text, text) Converts a string to a number. to_number('12,454.8-', '99G999D9S') -12454.8
to_timestamp(text, text) Converts a string to a timestamp. to_timestamp('05 Dec 2000', 'DD Mon YYYY') 2000-12-05 00:00:00+08
date - date Calculates the number of days between two dates. date '2001-10-01' - date '2001-09-28' integer '3' (days)
clock_timestamp() Returns the current time. clock_timestamp() | 2020-05-03 06:32:28.814918+08
current_date Returns the current date. current_date 2020-05-03
current_timestamp Returns the current timestamp. current_timestamp 2020-05-03 06:33:36.113682+08
date_part(text, timestamp) Returns a portion of a timestamp based on its arguments. date_part('hour', timestamp '2001-02-16 20:38:40') 20
date_trunc(text, timestamp) Truncates a timestamp to a specified precision. date_trunc('hour', timestamp '2001-02-16 20:38:40') 2001-02-16 20:00:00
extract(field from timestamp) Returns a portion of a timestamp based on its arguments. extract(hour from timestamp '2001-02-16 20:38:40') 20
isfinite(date) Determines whether a date is finite. isfinite(date '2001-02-16') true
isfinite(timestamp) Determines whether a timestamp is finite. isfinite(timestamp '2001-02-16 21:28:30') true
isfinite(interval) Determines whether an interval is finite. isfinite(interval '4 hours') true
make_date(year int, month int, day int) Creates a date from its separate year, month, and day fields. make_date(2013, 7, 15) 2013-07-15
localtimestamp Returns the current time that does not contain the time zone information. localtimestamp 2020-05-03 06:38:25.9474
now() Returns the current timestamp. now() 2020-05-03 06:38:48.492168+08
statement_timestamp() Returns the start time of the current statement. statement_timestamp() 2020-05-05 06:39:11.125957+08
timeofday() Returns the current time.
Note The returned value is a formatted string.
timeofday() Tue May 03 06:39:43.195368 2020 CST
transaction_timestamp() Returns the current timestamp. transaction_timestamp() 2020-05-03 06:40:08.023623+08
to_timestamp(double precision) Converts a Unix epoch value to a timestamp.
Note This Unix epoch value represents the number of seconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.
to_timestamp(1284352323) 2010-09-13 04:32:03+00