Results 1 to 2 of 2
  1. #1
    DMT Dave is online now VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,195

    Time Calculation

    Hi Guys, I have text box with ie: 15:38 (start time), how can I calculate the finish time and calculate the hours, the following is the log out button, I think if I am correct the setting as string maybe wrong ?

    Code:
    Dim DateNow As Date, TimeNow As String
    Dim MyName As String, TotalHrs As String
    DateNow = Format(Now(), "dd-mmm-yyyy")
    TimeNow = Format(Now(), "hh:nn")
    MyName = Me.cmdOutAF.Caption
    Me.txtOutAF = DateAdd("hh:nn", , Me.txtInAF)


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You shouldn't use String if you want to do math with the values. I'm not sure what all that is trying to accomplish, and the arguments for the DateAdd() are wrong. To calculate the elapsed time, I'd expect the DateDiff() function. Just use Now() in that without the formatting stuff.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 04-09-2018, 12:35 PM
  2. Time calculation
    By anlimah in forum Programming
    Replies: 1
    Last Post: 07-07-2014, 04:48 PM
  3. time difference calculation help
    By JayRab in forum Access
    Replies: 5
    Last Post: 02-03-2014, 01:32 PM
  4. Date & Time Calculation
    By pfales in forum Programming
    Replies: 5
    Last Post: 07-02-2013, 01:29 PM
  5. Time interval calculation
    By gar in forum Queries
    Replies: 3
    Last Post: 04-09-2013, 02:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums