Tuesday, July 28, 2009

How do I convert UNIX time to normal time in SQL?

I have a column of SAMPLEDATETIME in unix time. For example, one value is 633045792793177085, I want to convert this to normal dd/mm/yyyy hh:mm:ss time when I run my query. How do I do this?

How do I convert UNIX time to normal time in SQL?
may i ask why you are using anything unix?





http://nerdsex.istheshit.net/images/hlrz...





just go back to windows... UNIX is obsolete
Reply:FROM_UNIXTIME(unix_timestamp), FROM_UNIXTIME(unix_timestamp,format)





Returns a representation of the unix_timestamp argument as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. The value is expressed in the current time zone. unix_timestamp is an internal timestamp value such as is produced by the UNIX_TIMESTAMP() function.





If format is given, the result is formatted according to the format string, which is used the same way as listed in the entry for the DATE_FORMAT() function.





mysql%26gt; SELECT FROM_UNIXTIME(875996580);


-%26gt; '1997-10-04 22:23:00'


mysql%26gt; SELECT FROM_UNIXTIME(875996580) + 0;


-%26gt; 19971004222300


mysql%26gt; SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),


-%26gt; '%Y %D %M %h:%i:%s %x');


-%26gt; '2003 6th August 06:22:58 2003'


No comments:

Post a Comment