title: Date - time format issue in excel using VBScript
body: <p>The following code is used to calculate the duration between two dates, for example "<em>11/13/2012  11:21:41 AM</em>" and "<em>11/14/2012  2:32:59 PM</em>".  The function is producing the correct output, in this case: <strong>1:03:11</strong> (in dd:hh:mm format, so 1 day, 3 hours, and 11 minutes).  After calculation the script stores this value into a Cell, which up until now is perfect, and exactly the format I want.  After that, another script runs and moves that cells value depending on the needs and some logic in the script, and stores it to the required cell dynamically.  The problem I'm having is, the duration is getting "AM" or "PM" added to the value, which is incorrect, since this is a very specific (and FORMATTED) DURATION, and NOT an actual time of day, which Excel seems to be treating as a TIME value instead.</p>
  
  <p><strong><em>Here is the code used to measure the durations:</em></strong></p>
  
  <pre><code>Function TimeSpan(dt1,dt2)
  Dim dtTemp
  
  objExcel1.Application.ScreenUpdating = False
      If (IsDate(dt1) And IsDate(dt2)) = False Then
          TimeSpan = "00:00:00"
          Exit Function
      End If
  
      If dt2 &lt; dt1 Then
          dtTemp = dt2
          dt2 = dt1
          dt1 = dt2
      End If
              TimeSpan = objExcel1.Application.WorksheetFunction.Text((dt2 - dt1), "dd:hh:mm")'"dd:hh:mm:ss"
  
  objExcel1.Application.ScreenUpdating = False
  End 
  </code></pre>