473,405 Members | 2,334 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,405 software developers and data experts.

Rounding Down - Short Time

94
I have 2 fields in a table called [start_time] and [end_time]. They are both in short time format.

I am displaying these in a form with a calculated field to show the time duration as well. (ie. [duration] = [end_time]-[start_time]) this is also displayed in short time format.

Example
Expand|Select|Wrap|Line Numbers
  1. start time      end time      duration
  2. 12:00           12:50         00:50
  3. 12:00           13:10         01:10
  4. 12:00           13:59         01:59
  5. 12:00           14:45         02:45
What i now want to show is another column which will round the duration down to the nearest hour and display the figure as a number. So....

Expand|Select|Wrap|Line Numbers
  1. start time      end time      duration               duration rounded
  2. 12:00           12:50         00:50...would become...0
  3. 12:00           13:10         01:10...would become...1
  4. 12:00           13:59         01:59...would become...1
  5. 12:00           14:45         02:45...would become...2
I have tried a multitude of different ways including ROUND, LEFT, STR etc but have hit the wall. I keep coming unstuck due to the times actually being stored as numbers before they are fomatted into the readable short time.

Hope that made sense. Can anyone help me?
Jun 2 '08 #1
8 2788
NeoPa
32,556 Expert Mod 16PB
As an hour is stored as a twelfth of a day, and a day is a simple integer, you can simply multiply the value by twelve; round; divide the result by twelve.
Jun 2 '08 #2
youmike
69
For twelfth read twentyfourth, so multiply by 24, not 12.
Jun 3 '08 #3
Lewe22
94
Thank you both. I know have it rounding nicely except it will round normally. Any ideas how i would now get it to round DOWN to the nearest whole number?
Jun 3 '08 #4
Lewe22
94
Managed to figure it out using the INT function. Thanks for the suggestions!

Expand|Select|Wrap|Line Numbers
  1. =Int([txtDuration]*24)/24
Jun 3 '08 #5
Lewe22
94
On a similar note, do you know how i could reflect the duration column in minutes?

Example
Expand|Select|Wrap|Line Numbers
  1. duration               duration (mins)
  2. 00:50...would become....50
  3. 01:10...would become....70
  4. 01:59...would become...119
  5. 02:45...would become...165
Jun 3 '08 #6
NeoPa
32,556 Expert Mod 16PB
For twelfth read twentyfourth, so multiply by 24, not 12.
Thank you. You're absolutely right of course :)

I had a "Senior Moment".
Jun 3 '08 #7
NeoPa
32,556 Expert Mod 16PB
On a similar note, do you know how I could reflect the duration column in minutes?
There are 60 minutes in an hour. Give this a shot yourself. It's really just as easy as you'd expect. No surprises.
Jun 3 '08 #8
Lewe22
94
Oh yeah!!!! Now i feel stupid! Thanks NeoPa

Expand|Select|Wrap|Line Numbers
  1. =([txtduration]*24)*60
Jun 3 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ron Adam | last post by:
With all the discussion about numbers here and particularly in regards to prePEP concerning decimal data types got me wondering about how numbers are handled when it comes to rounding. And if that...
3
by: Norvin Laudon | last post by:
Hi, Can somebody explain the following, from the MSDN documentation for the "System.Convert.ToInt32(double)" function <quote> Return Value value rounded to the nearest 32-bit signed...
5
by: Jason | last post by:
I am having a rounding problem in a value i am trying to display in VB.NET. If I have the following code: Dim x As Single = 2726.795 Dim y As Single = Math.Round(2726.795, 2) Dim s as String =...
11
by: cj | last post by:
Lets assume all calculations are done with decimal data types so things are as precise as possible. When it comes to the final rounding to cut a check to pay dividends for example in VB rounding...
13
by: Shirsoft | last post by:
I have a 32 bit intel and 64 bit AMD machine. There is a rounding error in the 8th digit. Unfortunately because of the algorithm we use, the errors percolate into higher digits. C++ code is...
18
by: jdrott1 | last post by:
i'm trying to round my currency string to end in 9. it's for a pricing application. this is the function i'm using to get the item in currency: FormatCurrency(BoxCost, , , , TriState.True) if...
5
by: Spoon | last post by:
Hello everyone, I don't understand how the lrint() function works. long lrint(double x); The function returns the nearest long integer to x, consistent with the current rounding mode. It...
206
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
30
by: bdsatish | last post by:
The built-in function round( ) will always "round up", that is 1.5 is rounded to 2.0 and 2.5 is rounded to 3.0. If I want to round to the nearest even, that is my_round(1.5) = 2 # As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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.