時間の値からn秒前を計算する

<分類:値変換>
<使用例:ログ解析で使用>
<プログラム例>

Sub 文字列編集_時間の値からn秒前を計算する()
   Dim n As Long
   Dim t1 As Date
   Dim t2 As Date
   
   n = -5
   t1 = "00:00:00"
   t2 = Format(DateAdd("s", n, t1), "HH:NN:SS")
   MsgBox (t1 & "の" & n & "秒前は" & t2 & "です")

End Sub