pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Changing displayed time zone in RAISE NOTICE output?
7+ messages / 3 participants
[nested] [flat]

* Changing displayed time zone in RAISE NOTICE output?
@ 2023-01-11 21:00  Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Ron @ 2023-01-11 21:00 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>

How do I get clock_timestamp() to display the time in a different time zone?

This is America/Chicago, but I'd like to display it in a different TZ.

psql (12.12 (Ubuntu 12.12-1.pgdg18.04+1))
postgres=# DO $$
postgres$# BEGIN
postgres$# RAISE NOTICE '%', clock_timestamp();
postgres$# END$$;
NOTICE:  2023-01-11 14:52:34.408225-06
DO

-- 
Born in Arizona, moved to Babylonia.





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Changing displayed time zone in RAISE NOTICE output?
@ 2023-01-11 21:06  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Adrian Klaver @ 2023-01-11 21:06 UTC (permalink / raw)
  To: Ron <ronljohnsonjr@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On 1/11/23 13:00, Ron wrote:
> How do I get clock_timestamp() to display the time in a different time 
> zone?
> 
> This is America/Chicago, but I'd like to display it in a different TZ.
> 
> psql (12.12 (Ubuntu 12.12-1.pgdg18.04+1))
> postgres=# DO $$
> postgres$# BEGIN
> postgres$# RAISE NOTICE '%', clock_timestamp();
> postgres$# END$$;
> NOTICE:  2023-01-11 14:52:34.408225-06
> DO
> 

test(5432)=# select clock_timestamp();
         clock_timestamp
--------------------------------
  01/11/2023 13:05:54.646178 PST
(1 row)

test(5432)=# select clock_timestamp() at time zone 'UTC';
           timezone
----------------------------
  01/11/2023 21:06:04.742478


-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Changing displayed time zone in RAISE NOTICE output?
@ 2023-01-12 05:25  Ron <ronljohnsonjr@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Ron @ 2023-01-12 05:25 UTC (permalink / raw)
  To: pgsql-general <pgsql-general@lists.postgresql.org>

On 1/11/23 15:06, Adrian Klaver wrote:
> On 1/11/23 13:00, Ron wrote:
>> How do I get clock_timestamp() to display the time in a different time zone?
>>
>> This is America/Chicago, but I'd like to display it in a different TZ.
>>
>> psql (12.12 (Ubuntu 12.12-1.pgdg18.04+1))
>> postgres=# DO $$
>> postgres$# BEGIN
>> postgres$# RAISE NOTICE '%', clock_timestamp();
>> postgres$# END$$;
>> NOTICE:  2023-01-11 14:52:34.408225-06
>> DO
>>
>
> test(5432)=# select clock_timestamp();
>         clock_timestamp
> --------------------------------
>  01/11/2023 13:05:54.646178 PST
> (1 row)
>
> test(5432)=# select clock_timestamp() at time zone 'UTC';
>           timezone
> ----------------------------
>  01/11/2023 21:06:04.742478

Hmm.  I'd have sworn this didn't work when I tried it:

postgres=#
postgres=# DO $$
BEGIN
RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
END$$;
NOTICE:  2023-01-12 05:22:40.517299

But it does work, so all's well that ends well.

-- 
Born in Arizona, moved to Babylonia.





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Changing displayed time zone in RAISE NOTICE output?
@ 2023-01-12 15:38  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Adrian Klaver @ 2023-01-12 15:38 UTC (permalink / raw)
  To: Ron <ronljohnsonjr@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On 1/11/23 21:25, Ron wrote:
> On 1/11/23 15:06, Adrian Klaver wrote:

> 
> Hmm.  I'd have sworn this didn't work when I tried it:

Did you do?:

DO $$
BEGIN
RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';
END$$;
ERROR:  syntax error at or near "timezone"
LINE 3: RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';


> 
> postgres=#
> postgres=# DO $$
> BEGIN
> RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
> END$$;
> NOTICE:  2023-01-12 05:22:40.517299
> 
> But it does work, so all's well that ends well.
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Changing displayed time zone in RAISE NOTICE output?
@ 2023-01-12 16:22  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Pavel Stehule @ 2023-01-12 16:22 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Ron <ronljohnsonjr@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

čt 12. 1. 2023 v 16:39 odesílatel Adrian Klaver <adrian.klaver@aklaver.com>
napsal:

> On 1/11/23 21:25, Ron wrote:
> > On 1/11/23 15:06, Adrian Klaver wrote:
>
> >
> > Hmm.  I'd have sworn this didn't work when I tried it:
>
> Did you do?:
>
> DO $$
> BEGIN
> RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';
> END$$;
> ERROR:  syntax error at or near "timezone"
> LINE 3: RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';
>
>
there should be space >>AT TIME ZONE<<

(2023-01-12 17:21:10) postgres=# DO $$
BEGIN
RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
END$$;
NOTICE:  2023-01-12 16:21:14.063256
DO
(2023-01-12 17:21:14) postgres=#


>
> >
> > postgres=#
> > postgres=# DO $$
> > BEGIN
> > RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
> > END$$;
> > NOTICE:  2023-01-12 05:22:40.517299
> >
> > But it does work, so all's well that ends well.
> >
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>
>
>
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Changing displayed time zone in RAISE NOTICE output?
@ 2023-01-12 16:27  Adrian Klaver <adrian.klaver@aklaver.com>
  parent: Pavel Stehule <pavel.stehule@gmail.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Adrian Klaver @ 2023-01-12 16:27 UTC (permalink / raw)
  To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Ron <ronljohnsonjr@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

On 1/12/23 08:22, Pavel Stehule wrote:
> 
> 
> čt 12. 1. 2023 v 16:39 odesílatel Adrian Klaver 
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> napsal:
> 
>     On 1/11/23 21:25, Ron wrote:
>      > On 1/11/23 15:06, Adrian Klaver wrote:
> 
>      >
>      > Hmm.  I'd have sworn this didn't work when I tried it:
> 
>     Did you do?:
> 
>     DO $$
>     BEGIN
>     RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';
>     END$$;
>     ERROR:  syntax error at or near "timezone"
>     LINE 3: RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';
> 
> 
> there should be space >>AT TIME ZONE<<
> 
> (2023-01-12 17:21:10) postgres=# DO $$
> BEGIN
> RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
> END$$;
> NOTICE:  2023-01-12 16:21:14.063256
> DO
> (2023-01-12 17:21:14) postgres=#

Yeah I know, I was responding to Ron saying his previous attempt had 
failed. Using 'timezone' instead of 'time zone' is a mistake I have made 
often enough that I threw it out there as a possible cause for the failure.

> 
> 
>      >
>      > postgres=#
>      > postgres=# DO $$
>      > BEGIN
>      > RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
>      > END$$;
>      > NOTICE:  2023-01-12 05:22:40.517299
>      >
>      > But it does work, so all's well that ends well.
>      >
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 
> 
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Changing displayed time zone in RAISE NOTICE output?
@ 2023-01-12 16:29  Pavel Stehule <pavel.stehule@gmail.com>
  parent: Adrian Klaver <adrian.klaver@aklaver.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Pavel Stehule @ 2023-01-12 16:29 UTC (permalink / raw)
  To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: Ron <ronljohnsonjr@gmail.com>; pgsql-general <pgsql-general@lists.postgresql.org>

čt 12. 1. 2023 v 17:27 odesílatel Adrian Klaver <adrian.klaver@aklaver.com>
napsal:

> On 1/12/23 08:22, Pavel Stehule wrote:
> >
> >
> > čt 12. 1. 2023 v 16:39 odesílatel Adrian Klaver
> > <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>> napsal:
> >
> >     On 1/11/23 21:25, Ron wrote:
> >      > On 1/11/23 15:06, Adrian Klaver wrote:
> >
> >      >
> >      > Hmm.  I'd have sworn this didn't work when I tried it:
> >
> >     Did you do?:
> >
> >     DO $$
> >     BEGIN
> >     RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';
> >     END$$;
> >     ERROR:  syntax error at or near "timezone"
> >     LINE 3: RAISE NOTICE '%', clock_timestamp() at timezone 'UTC';
> >
> >
> > there should be space >>AT TIME ZONE<<
> >
> > (2023-01-12 17:21:10) postgres=# DO $$
> > BEGIN
> > RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
> > END$$;
> > NOTICE:  2023-01-12 16:21:14.063256
> > DO
> > (2023-01-12 17:21:14) postgres=#
>
> Yeah I know, I was responding to Ron saying his previous attempt had
> failed. Using 'timezone' instead of 'time zone' is a mistake I have made
> often enough that I threw it out there as a possible cause for the failure.
>

:-)


>
> >
> >
> >      >
> >      > postgres=#
> >      > postgres=# DO $$
> >      > BEGIN
> >      > RAISE NOTICE '%', clock_timestamp() at time zone 'UTC';
> >      > END$$;
> >      > NOTICE:  2023-01-12 05:22:40.517299
> >      >
> >      > But it does work, so all's well that ends well.
> >      >
> >
> >     --
> >     Adrian Klaver
> >     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> >
> >
> >
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>
>

^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2023-01-12 16:29 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-11 21:00 Changing displayed time zone in RAISE NOTICE output? Ron <ronljohnsonjr@gmail.com>
2023-01-11 21:06 ` Adrian Klaver <adrian.klaver@aklaver.com>
2023-01-12 05:25   ` Ron <ronljohnsonjr@gmail.com>
2023-01-12 15:38     ` Adrian Klaver <adrian.klaver@aklaver.com>
2023-01-12 16:22       ` Pavel Stehule <pavel.stehule@gmail.com>
2023-01-12 16:27         ` Adrian Klaver <adrian.klaver@aklaver.com>
2023-01-12 16:29           ` Pavel Stehule <pavel.stehule@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox