Results 1 to 8 of 8
  1. #1
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199

    Formatting subtraction of two numbers.


    How can I format the output of subtracting two times as a time value. For instance 10:00 am - 9:00 AM = 1 (where I want to show the output as "1").

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Are you using DateDiff() function?

    Converting the double value to a clock format requires an expression or custom function. See post 9 in https://www.accessforums.net/access/...ime-38266.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199
    Hi June7! I just tried DateDiff and that gets me pretty close. Can you advise on what interval to use in order to get the time in minutes. "h" works fine but rounds too high. "hh:nn" drops an error.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    "n" for minutes because "m" is already reserved for months.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199
    June7, yes I am using hh:nn (i also tried h:n) but thats erroring out in the field.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Neither of those is valid parameter for the DateDiff function.

    Did you look at the link in post 2?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    accessmatt is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    199
    June7,

    I re-read your other post but I didn't follow the formula you have there and the article on Access KB wasn't very useful for formatting as hh:mm.

    Thanks,

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Use of DateDiff() is clearly demonstrated.

    The conversion example given is for converting seconds to HH:mm:SS.

    The expression will have to be adjusted for converting minutes to HH:MM.

    DateDiff("n", enddate, startdate) will return total minutes

    x = elapsed time in decimal minutes

    Int(x / 60) & ":" & Int(x mod 60)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Formatting Numbers in a Chart
    By kristyspdx in forum Forms
    Replies: 1
    Last Post: 05-22-2014, 05:23 PM
  2. Formatting numbers to have a leading zero
    By blacksaibot in forum Queries
    Replies: 7
    Last Post: 04-26-2014, 09:52 AM
  3. Formatting Numbers in Decimal Places
    By bigmatt911 in forum Queries
    Replies: 3
    Last Post: 12-20-2013, 12:46 PM
  4. need help with formatting negative numbers
    By orientalmed in forum Access
    Replies: 3
    Last Post: 03-06-2013, 01:24 PM
  5. Formatting numbers in a report
    By bullwinkle55423 in forum Reports
    Replies: 1
    Last Post: 11-09-2010, 01:12 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