From b3506006b56487cc7ec440703ebc5d5835c55629 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 3 Sep 2002 22:55:54 +0000 Subject: [PATCH] EXTRACT(EPOCH FROM timestamp) gave wrong answers in the int64-timestamp case for timestamptz input, and differently wrong answers in the float- timestamp case for timestamp input. --- src/backend/utils/adt/timestamp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index a511e34410..a381fd47cd 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.71 2002/09/02 02:47:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.72 2002/09/03 22:55:54 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2871,7 +2871,11 @@ timestamp_part(PG_FUNCTION_ARGS) switch (val) { case DTK_EPOCH: +#ifdef HAVE_INT64_TIMESTAMP result = ((timestamp - SetEpochTimestamp()) / 1000000e0); +#else + result = timestamp - SetEpochTimestamp(); +#endif break; case DTK_DOW: @@ -3052,7 +3056,7 @@ timestamptz_part(PG_FUNCTION_ARGS) { case DTK_EPOCH: #ifdef HAVE_INT64_TIMESTAMP - result = ((timestamp - SetEpochTimestamp()) / 100000e0); + result = ((timestamp - SetEpochTimestamp()) / 1000000e0); #else result = timestamp - SetEpochTimestamp(); #endif