Re: How to extract epoch from clock_timestamp

From: Justin <zzzzz(dot)graf(at)gmail(dot)com>
To: "Subramanian,Ramachandran" <ramachandran(dot)subramanian(at)alte-leipziger(dot)de>
Cc: "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: Re: How to extract epoch from clock_timestamp
Date: 2026-08-21 17:49:16
Message-ID: CALL-XeNqtpK3yePps2QGMsSKAcjSqhLgaoBB6-AYBUcbUw86dQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi Subramanian,Ramachandran,

here is the correct syntax

select extract(EPOCH FROM clock_timestamp())

the two issues are timestamptz is unneeded and the function was put in
single quotes.

have a good day

On Fri, Aug 21, 2026 at 1:36 PM Subramanian,Ramachandran <
ramachandran(dot)subramanian(at)alte-leipziger(dot)de> wrote:

> Hello,
>
>
>
>
>
> I am trying to write a script that will monitor how many log records were
> cut in the past say 15 minutes.
>
>
>
> As a part of this, I need to extract epoch from clock_timestamp().
>
>
>
> However, the syntax I am using is wrong. What is the correct way to
> extract it and subtract it ? I would be grateful for your help.
>
>
>
>
>
>
>
>
>
>
>
> select timeofday(), current_date, current_time , pg_current_wal_lsn(),
> now() , clock_timestamp() ; à WORKS NO PROBLEM
>
>
>
> select extract(EPOCH FROM timestamptz 'clock_timestamp()'); -à SYNTAX IS
> WRONG DOES NOT WORK
>
>
>
> select extract(EPOCH FROM timestamptz 'now()') ; à SYNTAX IS CORRECT ,
> THIS WORKS
>
>
>
>
>
> select extract(EPOCH FROM timestamptz 'clock_timestamp()' - extract(EPOCH
> FROM timestamptz 'now()') );
>
>
>
>
>
> psql:check_logging_rate:5: ERROR: invalid input syntax for type timestamp
> with time zone: "clock_timestamp()"
>
> LINE 1: select extract(EPOCH FROM timestamptz 'clock_timestamp()' - ...
>
>
>
>
>
> Regards
>
>
>
> Ram
>
>
>
>
>
>
>
> Freundliche Grüße
>
> *i. A. Ramachandran Subramanian*
>
> Zentralbereich Informationstechnologie
>
> Alte Leipziger Lebensversicherung a. G.
>
> Hallesche Krankenversicherung a. G.
>
> ______________________
>
> ALH Gruppe
> Alte Leipziger-Platz 1, 61440 Oberursel
> Tel: +49 (6171) 66-4882
> Fax: +49 (6171) 66-800-4882
> E-Mail: ramachandran(dot)subramanian(at)alte-leipziger(dot)de
> www.alte-leipziger.de
> www.hallesche.de
>
> Alte Leipziger Lebensversicherung a. G., Alte Leipziger-Platz 1, 61440
> Oberursel
>
> Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn
> (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Robert Gladis, Dr. Jochen
> Kriegmeier, Alexander Mayer, Christian Pape, Udo Wilcsek
>
> Sitz Oberursel (Taunus) · Rechtsform VVaG · Amtsgericht Bad Homburg v. d.
> H. HRB 1583 · USt.-IdNr. DE 114106814
>
> Hallesche Krankenversicherung a. G., Löffelstraße 34-38, 70597 Stuttgart
>
> Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn
> (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Robert Gladis, Dr. Jochen
> Kriegmeier, Alexander Mayer, Christian Pape, Udo Wilcsek
>
> Sitz Stuttgart · Rechtsform VVaG · Amtsgericht Stuttgart HRB 2686 ·
> USt.-IdNr. DE 147802285
>
> Beiträge zu privaten Kranken- und Pflegekrankenversicherungen unterliegen
> nicht der Versicherungsteuer (§ 4 (1) Nr. 5 b VersStG) ·
> Versicherungsleistungen sowie Umsätze aus
> Versicherungsvertreter-/Maklertätigkeiten sind umsatzsteuerfrei
>
> Pflichtangaben <https://www.alte-leipziger.de/impressum> der ALH Gruppe
> gemäß § 35a GmbHG bzw. § 80 AktG
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message KK 2026-08-25 14:57:57 Disk layout for parallel instances
Previous Message Subramanian,Ramachandran 2026-08-21 17:36:10 How to extract epoch from clock_timestamp