title: C++ calculate difference between dates
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12386266/checking-two-tdatetime-variables">Checking two TDateTime variables</a>  </p>
  </blockquote>
  
  
  
  <p>I am having trouble calculating the difference between two dates and then displaying the difference. I have posted a previous question.</p>
  
  <p>I am after help with the replaceTime function. I am not sure how/why I need to use this.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>TDateTime testFirstDate("11/09/2012");
  TDateTime testFirstTime("14:00");
  
  TDateTime testSecondDate("12/09/2012");
  TDateTime testSecondTime("16:00");
  
  TDateTime testCombined1 = ReplaceTime(testFirstDate,testFirstTime);
  TDateTime testCombined2 = ReplaceTime(testSecondDate,testSecondTime);
  
  TDateTime testDateDifference = testCombined2 - testCombined1;
  
  std::cout &lt;&lt; testDateDifference;
  </code></pre>