title: CAST HEX as DATATIME - how to get date?
body: <p>I have a problem with processing a SQL Server database dump in PHP.</p>
  
  <p>I have one column called <code>datatime</code> with values like : </p>
  
  <pre><code>0x0000a0af00d7f2eb
  </code></pre>
  
  <p>I need to extract, in PHP, the date and time values of this column.  I don't have SQL Server available so I can't use the obvious solution of <code>CAST(0x0000a0af00d7f2eb AS datetime)</code>.</p>
  
  <p>Someone has told me that this hex: <code>0000a0af00d7f2eb</code> is created by 4 bytes of date and 4 bytes of time. </p>
  
  <p>So I know that: </p>
  
  <p>When I will change <code>0000a0af</code> (first 4 bytes) to decimal I will get number of days from 1900. That works fine.</p>
  
  <p>But when I'm trying to change last the 4 bytes (so there should be time) : <code>00d7f2eb</code> to decimal I'm getting something which I can't understand. It should be a time from midnight in milliseconds and sometimes this value is ~3 times lower.</p>
  
  <p>Could anyone help in converting <code>0000a0af00d7f2eb</code> to date? I know that time is between 5 AM and 11 PM, and the day is in last week.</p>