Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Mar 2001
    Location
    Bismarck, ND, USA
    Posts
    451
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm using the following in a control source on a report to express a running total in hours and minutes, even if the total is greater than 24 hours:

    =Int([txtrunsum])*24+DatePart("h",[txtrunsum]) & ":" & DatePart("n",[txtrunsum])

    It's working well, but if the minute portion is less than 10 minutes, the time is displayed as 36:5, for example. The toal is 5 minutes and I would like it displayed as 36:05.

    If the minutes are greater than 10 it displays correctly; 65:30, as an example.

    I'm hoping for a simple adjustment, as this really works well other than the minute issue!

    Thanks in advance.
    egghead

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Egghead,

    Could you please provide a sample [txtrunsum] value. I'm a bit puzzled since DatePart wants a Variant(Date) as the second argument and you seem to be passing it a string. I'm sure the string represents a date/time value but I'd just like to see what the function is getting.

    Thanks.
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    Lounger
    Join Date
    Jun 2010
    Location
    Manchester, NH
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Instead of =Int([txtrunsum])*24+DatePart("h",[txtrunsum]) & ":" & DatePart("n",[txtrunsum])

    Try: =Int([txtrunsum])*24+DatePart("h",[txtrunsum]) & ":" & Format(DatePart("n",[txtrunsum]), "00"))
    Bob Oxford
    Software Wizards, Inc.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •