• If it turns out that the time is stored in milliseconds with a base of 1970-01-01 00:00:00.000, then this code will work.

    -- Milliseconds since 1970-01-01 00:00:00.000

    declare @TimeMS bigint = 1397750400000;

    select

    [Date/Time] =

    -- Verify time can be converted to datetime

    case when @TimeMS between -6847804800001 and 253402300799998

    then dateadd(ms,@TimeMS%86400000,(@TimeMS/86400000)+25567)

    else null end

    Results:

    Date/Time

    -----------------------

    2014-04-17 16:00:00.000

    This will do the reverse conversion:

    declare @DateTime datetime = '2014-04-17 16:00:00.000'

    select

    TimeMS =

    (datediff(dd,25567,@DateTime)*00000086400000)+

    datediff(ms,dateadd(dd,datediff(dd,0,@DateTime),0),@DateTime)

    Results:

    TimeMS

    -------------------

    1397750400000

    Note:

    I just realized this is an old post, but the answer is correct if anyone cares.

    It's just a bit of code I had laying around from an old project. 😎