From e511d878f3bbc205cd260a79740e646eea3c1cd3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 29 Mar 2016 17:09:21 -0400 Subject: Allow to_timestamp(float8) to convert float infinity to timestamp infinity. With the original SQL-function implementation, such cases failed because we don't support infinite intervals. Converting the function to C lets us bypass the interval representation, which should be a bit faster as well as more flexible. Vitaly Burovoy, reviewed by Anastasia Lubennikova --- doc/src/sgml/func.sgml | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index e6c4ee52ee1..1bc9fbc4f51 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -5579,15 +5579,6 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}'); argument is the value to be formatted and the second argument is a template that defines the output or input format. - - A single-argument to_timestamp function is also - available; it accepts a - double precision argument and converts from Unix epoch - (seconds since 1970-01-01 00:00:00+00) to - timestamp with time zone. - (Integer Unix epochs are implicitly cast to - double precision.) - Formatting Functions @@ -5670,16 +5661,17 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}'); convert string to time stampto_timestamp('05 Dec 2000', 'DD Mon YYYY') - - to_timestamp(double precision) - timestamp with time zone - convert Unix epoch to time stamp - to_timestamp(1284352323) -
+ + + There is also a single-argument to_timestamp + function; see . + + + In a to_char output template string, there are certain patterns that are recognized and replaced with appropriately-formatted @@ -7060,8 +7052,8 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}'); timestamp with time zone Create timestamp with time zone from year, month, day, hour, minute - and seconds fields. When timezone is not specified, - then current time zone is used. + and seconds fields; if timezone is not + specified, the current time zone is used make_timestamptz(2013, 7, 15, 8, 15, 23.5) 2013-07-15 08:15:23.5+01 @@ -7127,6 +7119,19 @@ SELECT regexp_matches('abc01234xyz', '(?:(.*?)(\d+)(.*)){1,1}'); + + + + to_timestamp + + to_timestamp(double precision) + + timestamp with time zone + Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to + timestamp + to_timestamp(1284352323) + 2010-09-13 04:32:03+00 + @@ -7377,16 +7382,13 @@ SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'); - Here is how you can convert an epoch value back to a time - stamp: + You can convert an epoch value back to a time stamp + with to_timestamp: -SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720.12 * INTERVAL '1 second'; +SELECT to_timestamp(982384720.12); +Result: 2001-02-17 04:38:40.12+00 - - (The to_timestamp function encapsulates the above - conversion.) - -- cgit v1.2.3