date_trunc should be called date_round?

From: Mario Splivalo <mario(dot)splivalo(at)megafon(dot)hr>
To: pgsql <pgsql-sql(at)postgresql(dot)org>
Subject: date_trunc should be called date_round?
Date: 2009-06-29 08:47:16
Message-ID: 4A487F94.3070303@megafon.hr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

It's stated in the docs that date_trunc is "conceptually similar to the
trunc function for numbers.".

So, trunc(1.1) = 1, trunc(1.9) = 1, and so on.

But, date_trunc behaves like round function: round(1.9) = 2.

Example:

idel=# select date_trunc('milliseconds', '2009-01-01
12:15:00.000999+02'::timestamp with time zone);
date_trunc
----------------------------
2009-01-01 11:15:00.001+01
(1 row)

fidel=# select version();
version

----------------------------------------------------------------------------------------------------------
PostgreSQL 8.3.7 on x86_64-unknown-linux-gnu, compiled by GCC
gcc-4.3.real (Ubuntu 4.3.3-5ubuntu4) 4.3.3
(1 row)

Or am I again completely misreading something?

Mike

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Craig Ringer 2009-06-29 11:32:30 Re: uniqueness constraint with NULLs
Previous Message A. Kretschmer 2009-06-29 08:20:58 Re: uniqueness constraint with NULLs