Process time calc in vba

Posted on 2011-05-12
Last Modified: 2012-05-11
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?

Question by:PeterBaileyUk
    LVL 92

    Accepted Solution

    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 :)

    Author Closing Comment

    Thank u!

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    26 Experts available now in Live!

    Get 1:1 Help Now