sql - how to cast the hexadecimal to varchar(datetime)? -
i have datetime exporting "cast(0x0000987c00000000 datetime)" when want datetime.it null value. how can datetime again.
that looks sql server datetime
format. internally stored 2 integers first 4 bytes being days since 1st jan 1900 , 2nd being number of ticks since midnight (each tick being 1/300 of second).
if need use in mysql
select cast( '1900-01-01 00:00:00' + interval cast(conv(substr(hex(binarydata),1,8), 16, 10) signed) day + interval cast(conv(substr(hex(binarydata),9,8), 16, 10) signed)* 10000/3 microsecond datetime) converted_datetime ( select 0x0000987c00000000 binarydata union select 0x00009e85013711ee binarydata ) d
returns
converted_datetime -------------------------- 2006-11-17 00:00:00 2011-02-09 18:52:34.286667
(thanks ted hopp the solution in splitting binary data)
Comments
Post a Comment