| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | stepya(at)ukr(dot)net |
| Subject: | BUG #19935: comparing timestamps milliseocnds = microseconds |
| Date: | 2026-11-24 16:20:21 |
| Message-ID: | 19935-0f142ae1fe25372c@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19935
Logged by: Stepan Yankevych
Email address: stepya(at)ukr(dot)net
PostgreSQL version: 16.16
Operating system: RHEL 9.*
Description:
The issue is reproducible in up to 19 and looks like it is expected
behavior. but it is too strage behavior.
to_timestamp('20261124-09:57:25.000123', 'YYYYMMDD-hh:mi:ss.ms') evaluates
to 123 milliseconds, whereas the expected result is 0 milliseconds.
select to_timestamp('2026.11.24 09:57:25.123', 'YYYY.MM.DD-hh:mi:ss.ms') ,
to_timestamp('2026.11.24 09:57:25.000123', 'YYYY.MM.DD-hh:mi:ss.ms') ,
'2026.11.24 09:57:25.000123'::timestamp(3)
result is
to_timestamp |to_timestamp |timestamp |
--------------------------+--------------------------+-------------------+
2026-11-24 09:57:25.123-05|2026-11-24 09:57:25.123-05|2026-11-24 09:57:25|
Most confusingly, the following query returns true
select to_timestamp('2026.11.24 09:57:25.123', 'YYYY.MM.DD hh:mi:ss.ms') =
to_timestamp('2026.11.24 09:57:25.000123', 'YYYY.MM.DD hh:mi:ss.ms')
As far as i understand Postgres treats .123 and .000123 as substring after
'.' converted to int '000123'::int and '123'::int .
That is root cause of such behavior.
I'd suggest to use mulityply like (0.123*1000000)::int and
(0.000123*1000000)::int . So 123000 vs 123 now
It should fix the issue
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Matheus Alcantara | 2026-11-24 16:33:07 | Re: BUG #19931: postgres_fdw: FOR UPDATE over a pushed-down join ignores a pseudoconstant qual |
| Previous Message | Pavan | 2026-11-24 15:52:12 | Re: BUG #19919: Internal Invalidation Error During Savepoint DDL After Dropping a Domain Constraint |