Formatting a number as hours and minutes

Formatting a number as hours and minutes

am 14.04.2008 18:43:56 von Keith Tizzard

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?

Re: Formatting a number as hours and minutes

am 14.04.2008 19:12:21 von lyle

On Apr 14, 12:43=A0pm, Jim Devenish
wrote:
> I have a numeric field (double) which holds a number of hours. =A0I 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 =A0 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/store/We-Love-Math-with-Miss -Jenny-CD-and-Bo=
ok-Kit-p-1027.html

Re: Formatting a number as hours and minutes

am 14.04.2008 19:45:59 von Keith Tizzard

On Apr 14, 6:12=A0pm, lyle wrote:
> On Apr 14, 12:43=A0pm, Jim Devenish
> wrote:
>
> > I have a numeric field (double) which holds a number of hours. =A0I 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 =A0 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/store/We-Love-Math-with-Miss -Jenny-CD...

Most helpful. Maybe the display of 3.2 should have been 03:12

Re: Formatting a number as hours and minutes

am 14.04.2008 20:38:17 von lyle

On Apr 14, 1:45=A0pm, Jim Devenish wrote:
> On Apr 14, 6:12=A0pm, lyle wrote:
>
>
>
> > On Apr 14, 12:43=A0pm, Jim Devenish
> > wrote:
>
> > > I have a numeric field (double) which holds a number of hours. =A0I wi=
sh
> > > 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 =A0 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/store/We-Love-Math-with-Mis s-Jenny-CD...
>
> Most helpful. =A0Maybe the display of 3.2 should have been 03:12

Oh! Then maybe

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

Re: Formatting a number as hours and minutes

am 14.04.2008 20:45:07 von Keith Tizzard

On Apr 14, 7:38=A0pm, lyle wrote:
> On Apr 14, 1:45=A0pm, Jim Devenish wrote:
>
>
>
> > On Apr 14, 6:12=A0pm, lyle wrote:
>
> > > On Apr 14, 12:43=A0pm, Jim Devenish
> > > wrote:
>
> > > > I have a numeric field (double) which holds a number of hours. =A0I =
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 =A0 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/store/We-Love-Math-with-Mis s-Jenny-CD..=
..
>
> > Most helpful. =A0Maybe 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.

Re: Formatting a number as hours and minutes

am 14.04.2008 21:28:33 von Salad

lyle wrote:
> On Apr 14, 12:43 pm, Jim Devenish
> 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/store/We-Love-Math-with-Miss -Jenny-CD-and-Book-Kit-p-1027.html
>
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?"

http://seattlepi.nwsource.com/fun/rhymes.asp?date=20080412

Re: Formatting a number as hours and minutes

am 14.04.2008 23:57:38 von lyle

On Apr 14, 2:45=A0pm, Jim Devenish wrote:
> On Apr 14, 7:38=A0pm, lyle wrote:
>
>
>
> > On Apr 14, 1:45=A0pm, Jim Devenish wrote:=

>
> > > On Apr 14, 6:12=A0pm, lyle wrote:
>
> > > > On Apr 14, 12:43=A0pm, Jim Devenish
> > > > wrote:
>
> > > > > I have a numeric field (double) which holds a number of hours. =A0=
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 =A0 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/store/We-Love-Math-with-Mis s-Jenny-CD=
....
>
> > > Most helpful. =A0Maybe the display of 3.2 should have been 03:12
>
> > Oh! Then maybe
>
> > Format([TheHours] / 24, "hh:nn")
>
> That's a good start. =A0Now 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.

????????

Re: Formatting a number as hours and minutes

am 15.04.2008 00:19:39 von Keith Tizzard

On Apr 14, 10:57=A0pm, lyle wrote:
> On Apr 14, 2:45=A0pm, Jim Devenish wrote:
>
>
>
> > On Apr 14, 7:38=A0pm, lyle wrote:
>
> > > On Apr 14, 1:45=A0pm, Jim Devenish wrot=
e:
>
> > > > On Apr 14, 6:12=A0pm, lyle wrote:
>
> > > > > On Apr 14, 12:43=A0pm, Jim Devenish =

> > > > > wrote:
>
> > > > > > I have a numeric field (double) which holds a number of hours. =
=A0I 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 =A0 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/store/We-Love-Math-with-Mis s-Jenny-=
CD...
>
> > > > Most helpful. =A0Maybe the display of 3.2 should have been 03:12
>
> > > Oh! Then maybe
>
> > > Format([TheHours] / 24, "hh:nn")
>
> > That's a good start. =A0Now 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.

Re: Formatting a number as hours and minutes

am 15.04.2008 00:34:43 von Lyle Fairfield

Jim Devenish wrote in
news:70b616ce-b8a4-45b8-b3d2-da2fce1154d5@r9g2000prd.googleg roups.com:

> On Apr 14, 10:57 pm, lyle wrote:
>> On Apr 14, 2:45 pm, Jim Devenish
>> wrote:
>>
>>
>>
>> > On Apr 14, 7:38 pm, lyle wrote:
>>
>> > > On Apr 14, 1:45 pm, Jim Devenish
>> > > wrot
> e:
>>
>> > > > On Apr 14, 6:12 pm, lyle wrote:
>>
>> > > > > On Apr 14, 12:43 pm, Jim Devenish
>> > > > >
>
>> > > > > 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/store/We-Love-Math-with-Mis s-Je
>> > > > >nny-
> 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

Re: Formatting a number as hours and minutes

am 15.04.2008 13:36:15 von Keith Tizzard

On Apr 14, 11:34=A0pm, lyle fairfield wrote:
> Jim Devenish wrote innews:70b616ce-b8a4-45b=
8-b3d2-da2fce1154d5@r9g2000prd.googlegroups.com:
>
>
>
> > On Apr 14, 10:57=A0pm, lyle wrote:
> >> On Apr 14, 2:45=A0pm, Jim Devenish
> >> wrote:
>
> >> > On Apr 14, 7:38=A0pm, lyle wrote:
>
> >> > > On Apr 14, 1:45=A0pm, Jim Devenish
> >> > > wrot
> > e:
>
> >> > > > On Apr 14, 6:12=A0pm, lyle wrote:
>
> >> > > > > On Apr 14, 12:43=A0pm, Jim Devenish
> >> > > > >
>
> >> > > > > wrote:
>
> >> > > > > > I have a numeric field (double) which holds a number of
> >> > > > > > hours.
> > =A0I 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 =A0 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/store/We-Love-Math-with-Mis s-Je
> >> > > > >nny-
> > CD...
>
> >> > > > Most helpful. =A0Maybe the display of 3.2 should have been 03:12
>
> >> > > Oh! Then maybe
>
> >> > > Format([TheHours] / 24, "hh:nn")
>
> >> > That's a good start. =A0Now 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. =A0Simply hours and minutes.
>
> Public Function whatever()
> Dim TheHours#
>
> TheHours =3D 2.5
> Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn"=
)
>
> TheHours =3D 1.25
> Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn"=
)
>
> TheHours =3D 3.2
> Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn"=
)
>
> TheHours =3D 36.5
> Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn"=
)
>
> TheHours =3D 12345636.573489
> Debug.Print Format(-(-Int(TheHours)), "#0") & Format(TheHours / 24, "\:nn"=
)
>
> TheHours =3D 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.