From f3f6737af9ef1f5dc96faed3ba564137f3bc4dc3 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 10 Aug 2009 16:10:19 +0000 Subject: [PATCH] Adjust extract(epoch) example to clarify that it includes fractional seconds, per gripe from Richard Neill. Also, add a cross-reference to the to_timestamp function. --- doc/src/sgml/func.sgml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 4e5b08d8e4..4a890cb8b8 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ - + Functions and Operators @@ -6239,8 +6239,8 @@ SELECT EXTRACT(DOY FROM TIMESTAMP '2001-02-16 20:38:40'); -SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-08'); -Result: 982384720 +SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40.12-08'); +Result: 982384720.12 SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'); Result: 442800 @@ -6250,10 +6250,13 @@ SELECT EXTRACT(EPOCH FROM INTERVAL '5 days 3 hours'); Here is how you can convert an epoch value back to a time stamp: - -SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720 * INTERVAL '1 second'; +SELECT TIMESTAMP WITH TIME ZONE 'epoch' + 982384720.12 * INTERVAL '1 second'; + + (The to_timestamp function encapsulates the above + conversion.) +