title: VBA workout how many days, hours, minutes or seconds between two timestamps?
body: <p>I am trying to display the number of days or hours or minutes or seconds between two timestamps using vba.</p>
  
  <p>So far my code gives me the number of hours or days.</p>
  
  <pre><code>Sub Date_Dif()
  
      Dim d1 As Date
      d1 = Range("A8").Value
  
      Dim d2 As Date
      d2 = Now
  
      Dim hrsDiff As Long
      hrsDiff = DateDiff("h", d1, d2)
  
      ActiveSheet.Range("Z5").Value = IIf(hrsDiff &gt;= 24, _
                 hrsDiff \ 24 &amp; " days " &amp; hrsDiff Mod 24 &amp; " hours", _
                 hrsDiff &amp; " hours")
  
  End Sub
  </code></pre>
  
  <p>How can I adapt this to give me minutes or seconds as well?</p>
  
  <p>Thanks in advance</p>