From: | Marcos Pegoraro <marcos(at)f10(dot)com(dot)br> |
---|---|
To: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Understanding years part of Interval |
Date: | 2023-02-06 11:20:17 |
Message-ID: | CAB-JLwaO2UfyaSJ7198f2nGvg7b0fztRzhSfTaz-PXa_ju6HOQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-hackers |
I was just playing with some random timestamps for a week, for a month, for
a year ...
select distinct current_date+((random()::numeric)||'month')::interval from
generate_series(1,100) order by 1;
It´s with distinct clause because if you change that 'month' for a 'year'
it´ll return only 12 rows, instead of 100. So, why years part of interval
works differently than any other ?
select '1.01 week'::interval; --> 0 years 0 mons 7 days 1 hours 40 mins
48.00 secs
select '1.01 month'::interval; --> 0 years 1 mons 0 days 7 hours 12 mins
0.00 secs
select '1.01 year'::interval; --> 1 years 0 mons 0 days 0 hours 0 mins 0.00
secs
thanks
Marcos
From | Date | Subject | |
---|---|---|---|
Next Message | vignesh C | 2023-02-06 11:32:31 | Re: Support logical replication of DDLs |
Previous Message | Ajin Cherian | 2023-02-06 07:07:40 | Re: Support logical replication of DDLs |
From | Date | Subject | |
---|---|---|---|
Next Message | houzj.fnst@fujitsu.com | 2023-02-06 11:25:03 | RE: Perform streaming logical transactions by background workers and parallel apply |
Previous Message | Daniel Verite | 2023-02-06 11:16:13 | Re: proposal: psql: psql variable BACKEND_PID |