title: C++ store a modified MySQL timestamp as string
body: <p>I am currently trying to get a <code>DATETIME</code> key value from a MySQL database and save it as a string.</p>
  
  <p>However I dont want the time to be in the usual MySQL format <code>YYYY-MM-DD HH:MM:SS</code> but rather in a 12 hour format like this: <code>HH:MM:SS AM/PM</code></p>
  
  <p>I already figured out how to "convert" the time format in the MySQL database to my desired format by using this: </p>
  
  <pre><code>sql::ResultSet* time = database-&gt;Query("SELECT DATE_FORMAT(`lastLogin`, '%r') FROM `users` WHERE `user_id`='%i', id);
  </code></pre>
  
  <p>the MySQL command is valid and the Query returns the right time format (I tested it directly in MySQL).</p>
  
  <p>Now I want to store the result in a char* array but for some reason he always crashes with a SQL Invalid Command Exception when I try to copy the result in to the array.</p>
  
  <pre><code>time-&gt;first();
  char* lastLogin = new char[50];
  
  //here are the variants of the commands I tried, every one crashed:
  strcpy(lastLogin, time-&gt;getString("lastLogin").c_str());
  strcpy(lastLogin, time-&gt;getString("DATE_FORMAT(`lastLogin`, '%r')").c_str());
  strcpy(lastLogin, time-&gt;getString("DATE_FORMAT(lastLogin, '%r')").c_str());
  strcpy(lastLogin, time-&gt;getString(0).c_str());
  </code></pre>
  
  <p>does anybody know what I am doing wrong? Or is this even possible with MySQL Connector C++?</p>