Time field * Number field

M

Maracay

Hi Guys,

I am working on a report that I need to subtract to Time fields, tTo – tfrom
and I get the result I am saving it in another time field, that is perfect,
but now I need to multiply the result by a field number, and the result is
not what I was expecting, the problem must be that I am multiplying to
totally different data types, my question is who can I multiply 3:35 hours *
8.55 and get 28.64 as a result

Any help will be appreciated

Thanks
 
D

Douglas J. Steele

For the life of me, I can't understand what you'd get it you multiple a time
by another time, but the problem you're encountering is that Access really
isn't doesn't work well with time durations.

First of all, there's no Time data type in Access: the only time-related
data type is the Date data type. And the Date data type is really intended
to be used to store timestamps (actual points in time), as opposed to
durations (under the covers, it's an eight byte floating point number where
the integer portion represents the date as the number of days relative to 30
Dec, 1899 and the decimal portion represents the time as a fraction of a
day). A time of 3:35 would actually be stored as 0.149305555555556, while
8:55 would be stored as 0.371527777777778.

Your best bet would be to decide what granularity you need (seconds?
minutes?) and store the durations as Long Integers. In other words, if all
you cared about was minutes, store 3:35 as 215 (3 * 60 + 35) and if you
wanted seconds, store it as 12900 (3*60*60 + 35*60). Similarly, 8:55 would
be 535 minutes, or 32100 seconds. You could then write a function to convert
from total minutes or total seconds back to a time format.
 
D

Douglas J. Steele

Sorry: I just reread the question, and see you're not talking about
multiplying a time by a time.

Hopefullly, though, the discussion about how Access stored times shows why
you're having a problem.

What you need is to have 3:35 interpretted as 3.5833333. not as
0.149305555555556. Since, as I mentioned, times are stored as a fraction of
a day, and there are 24 hours in a day, multiply your time by 24:

?#3:35# * 24
3.58333333333333
 
M

Maracay

Thanks, is working.

Douglas J. Steele said:
Sorry: I just reread the question, and see you're not talking about
multiplying a time by a time.

Hopefullly, though, the discussion about how Access stored times shows why
you're having a problem.

What you need is to have 3:35 interpretted as 3.5833333. not as
0.149305555555556. Since, as I mentioned, times are stored as a fraction of
a day, and there are 24 hours in a day, multiply your time by 24:

?#3:35# * 24
3.58333333333333
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top