Re: absolute value fro timestamps
От | Claudio Lapidus |
---|---|
Тема | Re: absolute value fro timestamps |
Дата | |
Msg-id | BAY7-DAV34vJj3LsGlo000062c7@hotmail.com обсуждение исходный текст |
Ответ на | absolute value fro timestamps ("Claudio Lapidus" <clapidus@hotmail.com>) |
Ответы |
Re: absolute value fro timestamps
|
Список | pgsql-general |
Bruce Momjian wrote: > Why would you want an abolute value of a negative interval? Because I'm trying to match pairs of records that satisfy certain criteria, one of which is that both records have a timestamp that *may* be slightly offset between them, so I substract the two and the result must be no greater than the allowed offset. I don't know which record has the greater timestamp, so I don't know the sign of the substraction in advance. > > This works: > > test=> select -(interval '-1'); > ?column? > ---------- > 01:00:00 > (1 row) > > so I suppose you could create a function or CASE statement to get the > absolute value. > In the meantime I implemented it the following way: \set maxoffset 4 select ... where abs(extract(epoch from age(m1.ts, m2.ts))) < :maxoffset ... Which I think is more compact. Anyway, it would be nice to be able to write directly abs(age(m1.ts, m2.ts)) IMHO. thanks cl.
В списке pgsql-general по дате отправления: