Re: Error in date_trunc function?

Lists: pgsql-general
From: Marat Khairullin <xmm(at)rambler(dot)ru>
To: postgres-general <pgsql-general(at)postgresql(dot)org>
Subject: Error in date_trunc function?
Date: 2001-10-31 15:17:28
Message-ID: 20011031181728.540f6cf3.xmm@rambler.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


Compare TZ part of date_func function output with param 'month' and other.
Is it error?

netquote=> select date_trunc('century', now());
date_trunc
------------------------
2000-01-01 00:00:00+03
(1 row)

netquote=> select date_trunc('year', now());
date_trunc
------------------------
2001-01-01 00:00:00+03
(1 row)

netquote=> select date_trunc('month', now());
date_trunc
------------------------
2001-10-01 00:00:00+04
(1 row)

netquote=> select date_trunc('day', now());
date_trunc
------------------------
2001-10-31 00:00:00+03
(1 row)

netquote=> select date_trunc('hour', now());
date_trunc
------------------------
2001-10-31 18:00:00+03
(1 row)

netquote=> select date_trunc('minute', now());
date_trunc
------------------------
2001-10-31 18:12:00+03
(1 row)

netquote=> select date_trunc('second', now());
date_trunc
------------------------
2001-10-31 18:12:24+03
(1 row)

--
Marat Khairullin 8-> mailto:xmm(at)rambler(dot)ru
Marat(dot)Khairullin(at)f92(dot)n5049(dot)z2(dot)fidonet(dot)org


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marat Khairullin <xmm(at)rambler(dot)ru>
Cc: postgres-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Error in date_trunc function?
Date: 2001-11-01 03:48:37
Message-ID: 14984.1004586517@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Marat Khairullin <xmm(at)rambler(dot)ru> writes:
> Compare TZ part of date_func function output with param 'month' and other.
> Is it error?

Depends. Do those various dates fall in daylight-savings or standard-time
territory in your timezone? They all look like reasonable candidates
for local midnight to me, if you are in a northern-hemisphere zone that
switches to standard time sometime during October.

regards, tom lane


From: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
To: Marat Khairullin <xmm(at)rambler(dot)ru>
Cc: postgres-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Error in date_trunc function?
Date: 2001-11-01 05:26:13
Message-ID: 3BE0DCF5.CF0C91EA@fourpalms.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

...
> netquote=> select date_trunc('month', now());
> date_trunc
> ------------------------
> 2001-10-01 00:00:00+04

This one rotated the time back to daylight savings time (the transition
date was in October), hence the one hour jump from now(). You certainly
would not want to somehow preserve a time zone into a date for which it
is invalid, right?

- Thomas