[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

Process time calc in vba

I have two labels on a form: start time and end time and i would like to calculate the total processing time. The process might run over two dates so need to allow for that just in case.
Me.LblStartTime.Caption = "Start time: " & Now()
some processing
Me.LblEndTime.Caption = "End time: " & Now()

how do i get the difference in hours and minutes?

1 Solution
Patrick MatthewsCommented:
Something like this:

Dim StartAt As Date, EndAt As Date

StartAt = Now
Me.LblStartTime.Caption = "Start time: " & StartAt
' code
EndAt = Now
Me.LblEndTime.Caption = "End time: " & EndAt
Me.LblProcTime.Caption = "Processing time: " & Format(EndAt - StartAt, "hh:nn:ss")

Open in new window

That works as long as total time is less than 24 hours :)
PeterBaileyUkAuthor Commented:
Thank u!

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now