title: c++ Looking for a sane way to work with SqlServer data type datetime
body: <p>The SqlServer datetime data type is used to hold timestamps and it is 64 bits long - <a href="http://msdn.microsoft.com/en-us/library/ms187819.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms187819.aspx</a></p>
  
  <p>I am looking for a sane way to work with it in C++, something in the boost library, probably?</p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I would settle for being able to do these two operations:</p>
  
  <ul>
  <li>Display the timestamp in some human readable format, like <code>2012-01-15 16:54:13.123</code></li>
  <li>Parse a string like <code>2012-01-15 16:54:13.123</code> into the respective SqlServer datetime value.</li>
  </ul>
  
  <p><strong>EDIT2</strong></p>
  
  <p>Here is what I know until now. I have a table with a <code>datetime</code> column. When I select rows from it, I get this column back with the data type of <code>DBTYPE_DBTIMESTAMP</code>. According to <a href="http://msdn.microsoft.com/en-us/library/ms187819.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms187819.aspx</a> it should be an 8 byte value, however, I get back a 16 byte value, for instance:</p>
  
  <pre><code>00070015000c07db 00000000001f0007
  </code></pre>
  
  <p>I could not find any description of this format, but examining it reveals the following structure:</p>
  
  <pre><code>0007 0015 000c 07db 00000000 001f 0007
   ^    ^    ^    ^             ^    ^
   |    |    |    |             |    |
   |    |    |    |             |    +--- minutes (7)
   |    |    |    |             +----+--- seconds (31)
   |    |    |    +-------------+----+--- year    (2011)
   |    |    +----+-------------+----+--- month   (12)
   |    +----+----+-------------+----+--- day     (21)
   +----+----+----+-------------+----+--- hour    (7)
  </code></pre>
  
  <p>Which corresponds to <code>2011-12-21 07:07:31</code>. So, this appears to be easy, but where is the documentation? Are <code>DBTYPE_DBTIMESTAMP</code> values always reported in this format? Is it SqlSever CE specific or whether the Express and other flavours work the same? Can it contain milliseconds?</p>
  
  <p>BTW, I am using OLEDB to access the database.</p>