sql >> Base de Datos >  >> RDS >> Mysql

Cómo convertir UNIX TIME en formato de fecha y hora SQL

Puede usar la función de la siguiente manera:

select FROM_UNIXTIME(UNIX_TIMESTAMP(),'%a %b %d %H:%i:%s UTC %Y');

la salida será:

'Wed Feb 05 05:36:16 UTC 2014'

En su consulta

select COUNT(DISTINCT devices) AS "Devices",
  FROM_UNIXTIME(measure_tab.time,'%a %b %d %H:%i:%s UTC %Y') as d from measure_tab where 
  measure_tab.time >= 1375243200 and 
  measure_tab.time < 1375315200;

Para obtener más información, puede consultar la documentación:http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_from-unixtime

Puede ver sql fiddle:http://sqlfiddle.com/#!2/a2581/20357