Re: value returned by EXTRACT, date_part
От | Tom Lane |
---|---|
Тема | Re: value returned by EXTRACT, date_part |
Дата | |
Msg-id | [email protected] обсуждение исходный текст |
Ответ на | Re: value returned by EXTRACT, date_part (John Lumby <[email protected]>) |
Ответы |
Re: value returned by EXTRACT, date_part
|
Список | pgsql-sql |
John Lumby <[email protected]> <DM6PR06MB5562A231945B39D33623849BA3520@DM6PR06MB5562.namprd06.prod.outlook.com> writes: > But also (and probably not easily changed now) it would make EXTRACT > more generally useful if it included a fractional part for every field > type where meaningful. > Is there any reason why it should not? The SQL spec says otherwise. Section 4.6.2 "Datetimes" in SQL:2011 defines timestamps as containing the six fields year, month, day, hour, minute, second (dates contain only the first three, times only the second three, but otherwise are similar), plus possibly timezone_hour and timezone_minute. All of these except the seconds field are specified to be integers. Furthermore, the EXTRACT function is specifically defined to return one of these fields. 4.6.3 "Intervals" lays down basically the same sorts of rules for intervals: they are made of component fields and only the seconds field can have a fractional part. PG does offer a nonstandard EPOCH "field" in EXTRACT, which tries to convert the timestamp or interval as a whole to some number of seconds. Possibly you could make use of that, perhaps after first applying date_trunc, to get what you're after. The whole enterprise is pretty shaky though; for example you cannot convert months to days or vice versa without making fundamentally-indefensible assumptions. regards, tom lane
В списке pgsql-sql по дате отправления: