pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #18883: Epoch issue
2+ messages / 2 participants
[nested] [flat]

* BUG #18883: Epoch issue
@ 2025-04-08 12:00  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Bug reporting form @ 2025-04-08 12:00 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: ravi105173@gmail.com

The following bug has been logged on the website:

Bug reference:      18883
Logged by:          RAVI KANT BHUSHAN
Email address:      ravi105173@gmail.com
PostgreSQL version: 16.1
Operating system:   Windows 10
Description:        

Number of days calculation using EPOCH is not providing right answer:

Query:      SELECT (EXTRACT(EPOCH FROM ('2025-04-08 11:25:01'::timestamp -
'2025-03-13 15:33:30'::timestamp)) / 86400)::INT   
                    ==> output is 26, but right answer is 25 days



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

* Re: BUG #18883: Epoch issue
@ 2025-04-08 12:29  David G. Johnston <david.g.johnston@gmail.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2025-04-08 12:29 UTC (permalink / raw)
  To: ravi105173@gmail.com <ravi105173@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Tuesday, April 8, 2025, PG Bug reporting form <noreply@postgresql.org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference:      18883
> Logged by:          RAVI KANT BHUSHAN
> Email address:      ravi105173@gmail.com
> PostgreSQL version: 16.1
> Operating system:   Windows 10
> Description:
>
> Number of days calculation using EPOCH is not providing right answer:
>
> Query:      SELECT (EXTRACT(EPOCH FROM ('2025-04-08 11:25:01'::timestamp -
> '2025-03-13 15:33:30'::timestamp)) / 86400)::INT
>                     ==> output is 26, but right answer is 25 days
>
>
select 1.75::int; — yields 2

We don’t document the precise rules for what casting does but rounding
seems reasonable.  Use the floor function to get your expected answer.

David J.

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


end of thread, other threads:[~2025-04-08 12:29 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-04-08 12:00 BUG #18883: Epoch issue PG Bug reporting form <noreply@postgresql.org>
2025-04-08 12:29 ` David G. Johnston <david.g.johnston@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