I’m trying to convert this string “0x00009F0900000000” into a date either through MySql or Rails as I’m working on a migration.
Can’t find what format it is. Doesn’t look like there’s a way to convert hexadecimal value into a date through rails or mysql.
Solution found here: how to cast the hexadecimal to varchar(datetime)?
SELECT
CAST(
'1900-01-01 00:00:00' +
INTERVAL CAST(CONV(substr(HEX(BinaryData),1,8), 16, 10) AS SIGNED) DAY +
INTERVAL CAST(CONV(substr(HEX(BinaryData),9,8), 16, 10) AS SIGNED)* 10000/3 MICROSECOND
AS DATETIME) AS converted_datetime
FROM
(
SELECT 0x00009F0900000000 AS BinaryData
) d
In ruby (and ignoring time)