473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

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
9 6177
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: David | last post by:
Hi, I've had a search through google but couldn't really find the answer I was looking for.I'm new to PHP, so please take it <relatively> easy. I've created a script which runs some SNMP...
8
by: Ricky W. Hunt | last post by:
Is there a built-in function in VB.NET that will take a number of seconds (e.g. 243) and display it as: "04:03" (four hours, three minutes)? -- Thanks, Ricky W. Hunt freendeed
2
by: DWalker | last post by:
In Visual Studio (Visual Basic) .NET 2002, I noticed that this: Dim Elapsed as DateTime = Now - Now gives a "compile time" error (error in the IDE), saying that the '-' operator is not...
2
by: Mark | last post by:
I am running into a weird problem. I am using the following code: String.Format("{0:0}:{1:00}:{2:00}", Hours.ToString, Minutes.ToString, Seconds.ToString) Just say seconds is set to 1, it...
8
by: Mark | last post by:
hi, how might I convert a string like "5p" or "5pm" or "5:00p" or "5.00pm" etc.. to "17:00:00" (24-hour time) I want it so that it's really *NOT* picky and will accept just about anything as...
8
by: King | last post by:
Hi I have following MS Acess query Here is the query ID Name Prgm ID Client ID Date Start Time End Time Minutes C4 Trisha TIP DEK0703 7 /7 /2006...
4
by: Deniz Dogan | last post by:
Hello. I need help with a small problem I'm having. I want to make a function which takes an integer representing some time in milliseconds and returns the same time but formatted as...
2
by: freemld10 | last post by:
Hi guys, Can someone please help me to Format Numbers with commas. The script below have very large number without commas. To read numbers in trillions and billions are hard, without commas to...
4
realin
by: realin | last post by:
hi guys.. I have made a function which counts the numbers of days or hours or minutes from the current datetime to the give datetime.. but i am confused while displaying number of days along with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.