467,074 Members | 1,089 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,074 developers. It's quick & easy.

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?
Jun 27 '08 #1
  • viewed: 5608
Share:
9 Replies
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...it-p-1027.html

Jun 27 '08 #2
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
Jun 27 '08 #3
On Apr 14, 1:45*pm, Jim Devenish <internet.shopp...@foobox.comwrote:
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
Oh! Then maybe

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

Jun 27 '08 #4
On Apr 14, 7:38*pm, lyle <lyle.fairfi...@gmail.comwrote:
On Apr 14, 1:45*pm, Jim Devenish <internet.shopp...@foobox.comwrote:
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

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.
Jun 27 '08 #5
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" ?

http://www.songsforteaching.com/stor...it-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/rh...?date=20080412

Jun 27 '08 #6
On Apr 14, 2:45*pm, Jim Devenish <internet.shopp...@foobox.comwrote:
On Apr 14, 7:38*pm, lyle <lyle.fairfi...@gmail.comwrote:
On Apr 14, 1:45*pm, Jim Devenish <internet.shopp...@foobox.comwrote:
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
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.

????????

Jun 27 '08 #7
On Apr 14, 10:57*pm, lyle <lyle.fairfi...@gmail.comwrote:
On Apr 14, 2:45*pm, Jim Devenish <internet.shopp...@foobox.comwrote:
On Apr 14, 7:38*pm, lyle <lyle.fairfi...@gmail.comwrote:
On Apr 14, 1:45*pm, Jim Devenish <internet.shopp...@foobox.comwrote:
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
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.
Jun 27 '08 #8
Jim Devenish <in***************@foobox.comwrote in
news:70**********************************@r9g2000p rd.googlegroups.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" ?
>http://www.songsforteaching.com/stor...h-with-Miss-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
Jun 27 '08 #9
On Apr 14, 11:34*pm, lyle fairfield <lylef...@yah00.cawrote:
Jim Devenish <internet.shopp...@foobox.comwrote innews:70**********************************@r9g200 0prd.googlegroups.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" ?
>http://www.songsforteaching.com/stor...h-with-Miss-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
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.
Jun 27 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by David | last post: by
8 posts views Thread by Ricky W. Hunt | last post: by
2 posts views Thread by DWalker | last post: by
2 posts views Thread by Mark | last post: by
8 posts views Thread by Mark | last post: by
4 posts views Thread by Deniz Dogan | last post: by
realin
4 posts views Thread by realin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.