1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
test=# select now();
now
-------------------------------
2006-08-04 16:50:49.115187+02
(1 ligne)
test=# select * from test;
a
----------------------------
2006-08-01 16:47:34.203246
2006-08-02 16:47:36.563467
2006-08-03 16:47:38.92819
2006-08-04 16:47:42.036417
2006-08-05 16:47:45.170757
2006-08-06 16:47:47.638056
(6 lignes)
test=# select a, case when now()>a then now()-a else a-now() end as tri from test order by tri limit 1;
a | tri
----------------------------+-----------------
2006-08-04 16:47:42.036417 | 00:03:19.085394
(1 ligne) |