pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mario Splivalo <mario.splivalo@megafon.hr>
Cc: pgsql <pgsql-sql@postgresql.org>
Subject: Re: date_trunc should be called date_round?
Date: Mon, 29 Jun 2009 10:25:20 -0400
Message-ID: <11724.1246285520@sss.pgh.pa.us> (raw)
In-Reply-To: <4A487F94.3070303@megafon.hr>
References: <4A487F94.3070303@megafon.hr>

Mario Splivalo <mario.splivalo@megafon.hr> writes:
> But, date_trunc behaves like round function: round(1.9) = 2.

Hmm ... only for float timestamps, and only for the millisec/microsec
cases.

            case DTK_MILLISEC:
#ifdef HAVE_INT64_TIMESTAMP
                fsec = (fsec / 1000) * 1000;
#else
                fsec = rint(fsec * 1000) / 1000;
#endif
                break;
            case DTK_MICROSEC:
#ifndef HAVE_INT64_TIMESTAMP
                fsec = rint(fsec * 1000000) / 1000000;
#endif
                break;

I wonder if we should change this to use floor() instead.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <11724.1246285520@sss.pgh.pa.us>
Permalink:  ../11724.1246285520@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11724.1246285520@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mario.splivalo@megafon.hr
  Subject: Re: date_trunc should be called date_round?
  In-Reply-To: <11724.1246285520@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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