Re: date_trunc should be called date_round? - Mailing list pgsql-sql

From Tom Lane
Subject Re: date_trunc should be called date_round?
Date
Msg-id 11724.1246285520@sss.pgh.pa.us
Whole thread Raw
In response to date_trunc should be called date_round?  (Mario Splivalo <mario.splivalo@megafon.hr>)
Responses Re: date_trunc should be called date_round?  (Mario Splivalo <mario.splivalo@megafon.hr>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: uniqueness constraint with NULLs
Next
From: Robert Edwards
Date:
Subject: Re: uniqueness constraint with NULLs