Mi tabla se ve así:
Inventario
inventory | creationDate {} | 2017-04-27 14:15:15.25+02 {} | 2017-04-27 13:03:02.205+02 {} | 2017-04-27 13:03:01.766+02 {} | 2017-04-27 13:02:19.8+02 {} | 2017-04-27 12:35:52.12+02La consulta:
SELECT * FROM "Inventory" WHERE "registerTillInventoryId" = 1 AND "creationDate" <= '2017-04-27 12:02:38.000 +00:00' ORDER BY "creationDate" DESC;El resultado:
inventory | creationDate {} | 2017-04-27 13:03:02.205+02 {} | 2017-04-27 13:03:01.766+02 {} | 2017-04-27 13:02:19.8+02 {} | 2017-04-27 12:35:52.12+02Mi pregunta es por qué obtengo los datos de
13:03:02.205+02 and 13:03:01.766+02El resultado de mi consulta debe ser
inventory | creationDate {} | 2017-04-27 13:02:19.8+02 {} | 2017-04-27 12:35:52.12+02'2017-04-27 12:02:38.000 +00:00' es '2017-04-27 14:02:38.000 +00:02' , por lo que devuelve todo menos '2017-04-27 14:15:15.25+02' ya que es el único valor que no cumple "creationDate" <= '2017-04-27 12:02:38.000 +00:00'
lo cual está bien. ejemplo:
t=# with a as (select '2017-04-27 12:02:38.000 +00:00' at time zone 'utc' ts) select ts, ts at time zone 'gmt+2' from a; ts | timezone ---------------------+------------------------ 2017-04-27 12:02:38 | 2017-04-27 14:02:38+00 (1 row) Time: 0.480 ms ¿por qué no simplemente "creationDate" <= '2017-04-27 12:02:38.000' para evitar mezclar tz?...
Bien, gracias por la ayuda. Resolví el problema con la ayuda del Comentario de Vao Tsun.
Lo que no describí fue que traté de obtener 13:02 de 12:02 +00:00
Realmente no necesito las zonas horarias. Entonces si pregunto
creationDate < '2017-04-27 13:02:38.000'directamente. Sin zonas horarias obtengo mi resultado correcto.
{} | 2017-04-27 13:02:19.8+02 {} | 2017-04-27 12:35:52.12+02 ...