Oracle SQL: marcas de tiempo en la cláusula where
Necesito buscar filas que caen bajo el marco de tiempo particular.
select *
from TableA
where startdate >= '12-01-2012 21:24:00'
and startdate <= '12-01-2012 21:25:33'
Es decir, buscar filas con precisión de marca de tiempo de segundos, ¿cómo logro esto?
35
1 answers
Necesitas usar to_timestamp () para convertir tu cadena a un valor de marca de tiempo apropiado:
to_timestamp('12-01-2012 21:24:00', 'dd-mm-yyyy hh24:mi:ss')
Si su columna es de tipo DATE
(que también admite segundos), debe usar to_date ()
to_date('12-01-2012 21:24:00', 'dd-mm-yyyy hh24:mi:ss')
Para obtener esto en una condición where use lo siguiente:
select *
from TableA
where startdate >= to_timestamp('12-01-2012 21:24:00', 'dd-mm-yyyy hh24:mi:ss')
and startdate <= to_timestamp('12-01-2012 21:25:33', 'dd-mm-yyyy hh24:mi:ss')
Nunca necesita usar to_timestamp()
en una columna que sea de tipo 'timestamp'
Editar error corregido
80
Author: a_horse_with_no_name,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-28 16:15:41
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-04-28 16:15:41