How to cast MSSQL Datetime in MYSQL

If any one mograte MSSQl data to MYSQl then there will be issue related to datetime column. SQL management studio generate script export the datetime value to hex value and MYSQL doesn’t recognized it.

To solve this issue just create a function and called it where required.

create function sp_ConvertSQLServerDate(dttm binary(16))
returns datetime
return CAST(
‘1900-01-01 00:00:00’ +
INTERVAL CAST(CONV(substr(HEX(dttm),1,8), 16, 10) AS SIGNED) DAY +
INTERVAL CAST(CONV(substr(HEX(dttm),9,8), 16, 10) AS SIGNED)* 10000/3 MICROSECOND
AS DATETIME);

and how to use it in MYSQL:

SELECT sp_ConvertSQLServerDate(0x00009E3000C98FF6) AS BinaryData