Formatting a number as hours and minutes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Devenish

    Formatting a number as hours and minutes

    I have a numeric field (double) which holds a number of hours. I wish
    to display this on a report in the form of hours and minutes.

    E.g.
    2.5 to be displayed as 02:30
    1.25 as 01:15
    3.2 as 03.20

    Using Format([theHours],"hh:nn") does not do it.

    Any ideas?


  • lyle

    #2
    Re: Formatting a number as hours and minutes

    On Apr 14, 12:43 pm, Jim Devenish <internet.shopp ...@foobox.com>
    wrote:
    I have a numeric field (double) which holds a number of hours.  I wish
    to display this on a report in the form of hours and minutes.
    >
    E.g.
    2.5 to be displayed as 02:30
    1.25 as 01:15
    3.2   as 03.20
    >
    Using Format([theHours],"hh:nn") does not do it.
    >
    Any ideas?
    Maybe "We Love Math with Miss Jenny" ?



    Comment

    • Jim Devenish

      #3
      Re: Formatting a number as hours and minutes

      On Apr 14, 6:12 pm, lyle <lyle.fairfi... @gmail.comwrote :
      On Apr 14, 12:43 pm, Jim Devenish <internet.shopp ...@foobox.com>
      wrote:
      >
      I have a numeric field (double) which holds a number of hours.  I wish
      to display this on a report in the form of hours and minutes.
      >
      E.g.
      2.5 to be displayed as 02:30
      1.25 as 01:15
      3.2   as 03.20
      >
      Using Format([theHours],"hh:nn") does not do it.
      >
      Any ideas?
      >
      Maybe "We Love Math with Miss Jenny" ?
      >
      http://www.songsforteaching.com/stor...-Miss-Jenny-CD...
      Most helpful. Maybe the display of 3.2 should have been 03:12


      Comment

      • lyle

        #4
        Re: Formatting a number as hours and minutes

        On Apr 14, 1:45 pm, Jim Devenish <internet.shopp ...@foobox.comw rote:
        On Apr 14, 6:12 pm, lyle <lyle.fairfi... @gmail.comwrote :
        >
        >
        >
        On Apr 14, 12:43 pm, Jim Devenish <internet.shopp ...@foobox.com>
        wrote:
        >
        I have a numeric field (double) which holds a number of hours.  I wish
        to display this on a report in the form of hours and minutes.
        >
        E.g.
        2.5 to be displayed as 02:30
        1.25 as 01:15
        3.2   as 03.20
        >
        Using Format([theHours],"hh:nn") does not do it.
        >
        Any ideas?
        >
        Maybe "We Love Math with Miss Jenny" ?
        >>
        Most helpful.  Maybe the display of 3.2 should have been 03:12
        Oh! Then maybe

        Format([TheHours] / 24, "hh:nn")

        Comment

        • Jim Devenish

          #5
          Re: Formatting a number as hours and minutes

          On Apr 14, 7:38 pm, lyle <lyle.fairfi... @gmail.comwrote :
          On Apr 14, 1:45 pm, Jim Devenish <internet.shopp ...@foobox.comw rote:
          >
          >
          >
          On Apr 14, 6:12 pm, lyle <lyle.fairfi... @gmail.comwrote :
          >
          On Apr 14, 12:43 pm, Jim Devenish <internet.shopp ...@foobox.com>
          wrote:
          >
          I have a numeric field (double) which holds a number of hours.  I wish
          to display this on a report in the form of hours and minutes.
          >
          E.g.
          2.5 to be displayed as 02:30
          1.25 as 01:15
          3.2   as 03.20
          >
          Using Format([theHours],"hh:nn") does not do it.
          >
          Any ideas?
          >
          Maybe "We Love Math with Miss Jenny" ?
          >>
          Most helpful.  Maybe the display of 3.2 should have been 03:12
          >
          Oh! Then maybe
          >
          Format([TheHours] / 24, "hh:nn")
          That's a good start. Now I will work out how to represent it when
          theHours>24.

          Comment

          • Salad

            #6
            Re: Formatting a number as hours and minutes

            lyle wrote:
            On Apr 14, 12:43 pm, Jim Devenish <internet.shopp ...@foobox.com>
            wrote:
            >
            >>I have a numeric field (double) which holds a number of hours. I wish
            >>to display this on a report in the form of hours and minutes.
            >>
            >>E.g.
            >>2.5 to be displayed as 02:30
            >>1.25 as 01:15
            >>3.2 as 03.20
            >>
            >>Using Format([theHours],"hh:nn") does not do it.
            >>
            >>Any ideas?
            >
            >
            Maybe "We Love Math with Miss Jenny" ?
            >

            >
            There was a cartoon in my local Saturday newspaper and I thought I'd
            pass it on to you. The strip is called "Rhymes with Orange". Caption 1
            says "Lyle's very short career in Forestry". In the second caption
            theres a few stumps and logs, one tree slanted downward and a man with a
            chain saw in front of a tree and he's looking around asking "Tim who?"



            Comment

            • lyle

              #7
              Re: Formatting a number as hours and minutes

              On Apr 14, 2:45 pm, Jim Devenish <internet.shopp ...@foobox.comw rote:
              On Apr 14, 7:38 pm, lyle <lyle.fairfi... @gmail.comwrote :
              >
              >
              >
              On Apr 14, 1:45 pm, Jim Devenish <internet.shopp ...@foobox.comw rote:
              >
              On Apr 14, 6:12 pm, lyle <lyle.fairfi... @gmail.comwrote :
              >
              On Apr 14, 12:43 pm, Jim Devenish <internet.shopp ...@foobox.com>
              wrote:
              >
              I have a numeric field (double) which holds a number of hours.  I wish
              to display this on a report in the form of hours and minutes.
              >
              E.g.
              2.5 to be displayed as 02:30
              1.25 as 01:15
              3.2   as 03.20
              >
              Using Format([theHours],"hh:nn") does not do it.
              >
              Any ideas?
              >
              Maybe "We Love Math with Miss Jenny" ?
              >>
              Most helpful.  Maybe the display of 3.2 should have been 03:12
              >
              Oh! Then maybe
              >
              Format([TheHours] / 24, "hh:nn")
              >
              That's a good start.  Now I will work out how to represent it when
              theHours>24.
              Let us know! I guess you've worked out what the results are that you
              want for say

              36.5 ?

              Maybe

              1 12:30

              or

              36:30

              or

              12:30.

              ????????

              Comment

              • Jim Devenish

                #8
                Re: Formatting a number as hours and minutes

                On Apr 14, 10:57 pm, lyle <lyle.fairfi... @gmail.comwrote :
                On Apr 14, 2:45 pm, Jim Devenish <internet.shopp ...@foobox.comw rote:
                >
                >
                >
                On Apr 14, 7:38 pm, lyle <lyle.fairfi... @gmail.comwrote :
                >
                On Apr 14, 1:45 pm, Jim Devenish <internet.shopp ...@foobox.comw rote:
                >
                On Apr 14, 6:12 pm, lyle <lyle.fairfi... @gmail.comwrote :
                >
                On Apr 14, 12:43 pm, Jim Devenish <internet.shopp ...@foobox.com>
                wrote:
                >
                I have a numeric field (double) which holds a number of hours.  I wish
                to display this on a report in the form of hours and minutes.
                >
                E.g.
                2.5 to be displayed as 02:30
                1.25 as 01:15
                3.2   as 03.20
                >
                Using Format([theHours],"hh:nn") does not do it.
                >
                Any ideas?
                >
                Maybe "We Love Math with Miss Jenny" ?
                >>
                Most helpful.  Maybe the display of 3.2 should have been 03:12
                >
                Oh! Then maybe
                >
                Format([TheHours] / 24, "hh:nn")
                >
                That's a good start.  Now I will work out how to represent it when
                theHours>24.
                >
                Let us know! I guess you've worked out what the results are that you
                want for say
                >
                36.5 ?
                >
                Maybe
                >
                1 12:30
                >
                or
                >
                36:30
                >
                or
                >
                12:30.
                >
                ????????
                I want the display to be 36:30. Simply hours and minutes.

                Comment

                • lyle fairfield

                  #9
                  Re: Formatting a number as hours and minutes

                  Jim Devenish <internet.shopp ing@foobox.comw rote in
                  news:70b616ce-b8a4-45b8-b3d2-da2fce1154d5@r9 g2000prd.google groups.com:
                  On Apr 14, 10:57 pm, lyle <lyle.fairfi... @gmail.comwrote :
                  >On Apr 14, 2:45 pm, Jim Devenish <internet.shopp ...@foobox.com>
                  >wrote:
                  >>
                  >>
                  >>
                  On Apr 14, 7:38 pm, lyle <lyle.fairfi... @gmail.comwrote :
                  >>
                  On Apr 14, 1:45 pm, Jim Devenish <internet.shopp ...@foobox.com>
                  wrot
                  e:
                  >>
                  On Apr 14, 6:12 pm, lyle <lyle.fairfi... @gmail.comwrote :
                  >>
                  On Apr 14, 12:43 pm, Jim Devenish
                  <internet.shopp ...@foobox.com>
                  >
                  wrote:
                  >>
                  I have a numeric field (double) which holds a number of
                  hours.
                   I wish
                  to display this on a report in the form of hours and
                  minutes.
                  >>
                  E.g.
                  2.5 to be displayed as 02:30
                  1.25 as 01:15
                  3.2   as 03.20
                  >>
                  Using Format([theHours],"hh:nn") does not do it.
                  >>
                  Any ideas?
                  >>
                  Maybe "We Love Math with Miss Jenny" ?
                  >>
                  CD...
                  >>
                  Most helpful.  Maybe the display of 3.2 should have been 03:12
                  >>
                  Oh! Then maybe
                  >>
                  Format([TheHours] / 24, "hh:nn")
                  >>
                  That's a good start.  Now I will work out how to represent it when
                  theHours>24.
                  >>
                  >Let us know! I guess you've worked out what the results are that you
                  >want for say
                  >>
                  >36.5 ?
                  >>
                  >Maybe
                  >>
                  >1 12:30
                  >>
                  >or
                  >>
                  >36:30
                  >>
                  >or
                  >>
                  >12:30.
                  >>
                  >????????
                  >
                  I want the display to be 36:30. Simply hours and minutes.
                  >
                  Public Function whatever()
                  Dim TheHours#

                  TheHours = 2.5
                  Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")

                  TheHours = 1.25
                  Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")

                  TheHours = 3.2
                  Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")

                  TheHours = 36.5
                  Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")

                  TheHours = 12345636.573489
                  Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")

                  TheHours = 0.573489
                  Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")

                  End Function

                  2:30
                  1:15
                  3:12
                  36:30
                  12345636:34
                  0:34

                  Comment

                  • Jim Devenish

                    #10
                    Re: Formatting a number as hours and minutes

                    On Apr 14, 11:34 pm, lyle fairfield <lylef...@yah00 .cawrote:
                    Jim Devenish <internet.shopp ...@foobox.comw rote innews:70b616ce-b8a4-45b8-b3d2-da2fce1154d5@r9 g2000prd.google groups.com:
                    >
                    >
                    >
                    On Apr 14, 10:57 pm, lyle <lyle.fairfi... @gmail.comwrote :
                    On Apr 14, 2:45 pm, Jim Devenish <internet.shopp ...@foobox.com>
                    wrote:
                    >
                    On Apr 14, 7:38 pm, lyle <lyle.fairfi... @gmail.comwrote :
                    >
                    On Apr 14, 1:45 pm, Jim Devenish <internet.shopp ...@foobox.com>
                    wrot
                    e:
                    >
                    On Apr 14, 6:12 pm, lyle <lyle.fairfi... @gmail.comwrote :
                    >
                    On Apr 14, 12:43 pm, Jim Devenish
                    <internet.shopp ...@foobox.com>
                    >
                    wrote:
                    >
                    I have a numeric field (double) which holds a number of
                    hours.
                     I wish
                    to display this on a report in the form of hours and
                    minutes.
                    >
                    E.g.
                    2.5 to be displayed as 02:30
                    1.25 as 01:15
                    3.2   as 03.20
                    >
                    Using Format([theHours],"hh:nn") does not do it.
                    >
                    Any ideas?
                    >
                    Maybe "We Love Math with Miss Jenny" ?
                    >>
                    Most helpful.  Maybe the display of 3.2 should have been 03:12
                    >
                    Oh! Then maybe
                    >
                    Format([TheHours] / 24, "hh:nn")
                    >
                    That's a good start.  Now I will work out how to represent it when
                    theHours>24.
                    >
                    Let us know! I guess you've worked out what the results are that you
                    want for say
                    >
                    36.5 ?
                    >
                    Maybe
                    >
                    1 12:30
                    >
                    or
                    >
                    36:30
                    >
                    or
                    >
                    12:30.
                    >
                    ????????
                    >
                    I want the display to be 36:30.  Simply hours and minutes.
                    >
                    Public Function whatever()
                    Dim TheHours#
                    >
                    TheHours = 2.5
                    Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")
                    >
                    TheHours = 1.25
                    Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")
                    >
                    TheHours = 3.2
                    Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")
                    >
                    TheHours = 36.5
                    Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")
                    >
                    TheHours = 12345636.573489
                    Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")
                    >
                    TheHours = 0.573489
                    Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn")
                    >
                    End Function
                    >
                    2:30
                    1:15
                    3:12
                    36:30
                    12345636:34
                    0:34
                    Many thanks. Works a charm.

                    Not sure why you have put in a double negative: Format(-(-Int ....
                    I had not appreciated that to display the minutes, the first argument
                    to Format needed to be in days.


                    Comment

                    Working...