PC Review


Reply
Thread Tools Rate Thread

Calculating time in minutes - whole minutes v. decimals

 
 
=?Utf-8?B?SnVkeSBpbiBBbGxlbnRvd24=?=
Guest
Posts: n/a
 
      10th Oct 2006
I wrote an expression in a query as follows:
Expr1: ([TIME OUT]-[TIME IN])*1440

For instance: 11/24/2006 11:00:00PM - 11/24/2006 10:59PM = 1 minute

However the result comes up as 1.00000000325963. How do I change the result
to a whole number in a query?

Thank you


 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2xhdHV1?=
Guest
Posts: n/a
 
      10th Oct 2006
It is always best to use date/time functions when dealing with date/time data
types. The fraction you are getting represents the seconds. The correct
function should be:
Expr1: DateDiff("n",[TIME IN], [TIME OUT])

"Judy in Allentown" wrote:

> I wrote an expression in a query as follows:
> Expr1: ([TIME OUT]-[TIME IN])*1440
>
> For instance: 11/24/2006 11:00:00PM - 11/24/2006 10:59PM = 1 minute
>
> However the result comes up as 1.00000000325963. How do I change the result
> to a whole number in a query?
>
> Thank you
>
>

 
Reply With Quote
 
=?Utf-8?B?Z2VlYmVl?=
Guest
Posts: n/a
 
      10th Oct 2006
hi,

Try Format([Expr1],"0")
OR
Try Format(([TIME OUT]-[TIME IN])*1440, "0")

Hope this helps,
geebee

"Judy in Allentown" wrote:

> I wrote an expression in a query as follows:
> Expr1: ([TIME OUT]-[TIME IN])*1440
>
> For instance: 11/24/2006 11:00:00PM - 11/24/2006 10:59PM = 1 minute
>
> However the result comes up as 1.00000000325963. How do I change the result
> to a whole number in a query?
>
> Thank you
>
>

 
Reply With Quote
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      10th Oct 2006
You could use the Round function to round the number to an integer:

Round((TIME OUT]-[TIME IN])*1440)

I wouldn't be completely confident that you would not find that would give
an incorrect result in some circumstances, however, rounding up or down when
you want the opposite, due to the way Access implements date/time values as a
64 bit floating point number as an offset from 30 December 1899 00:00:00.

Another approach would be to compute the difference in nominal seconds and
use integer division to convert it to minutes:

(([Time In] - [Time Out]) *86400)\60

But the safest way would be to use the DateDiff function:

DateDiff("n", [Time In], [Time Out])

The "n" as the first argument causes it to return the result in minutes. It
uses "n" because "m" is used for months.

Ken Sheridan
Stafford, England

"Judy in Allentown" wrote:

> I wrote an expression in a query as follows:
> Expr1: ([TIME OUT]-[TIME IN])*1440
>
> For instance: 11/24/2006 11:00:00PM - 11/24/2006 10:59PM = 1 minute
>
> However the result comes up as 1.00000000325963. How do I change the result
> to a whole number in a query?
>
> Thank you
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating time using minutes. computerkiller Microsoft Word Document Management 3 4th May 2010 04:07 AM
Converting Time from Hours and Minutes Decimals in a formula SARGE Microsoft Excel Misc 1 15th Nov 2008 09:39 PM
convert time in decimals to minutes joaniemic Microsoft Excel Misc 2 1st May 2008 05:22 PM
time from minutes to decimals =?Utf-8?B?TWFydGlu?= Microsoft Excel New Users 3 26th Aug 2006 09:40 AM
Calculating Minutes and Time =?Utf-8?B?TWljaGFlbGE=?= Microsoft Excel Programming 2 11th Feb 2005 04:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:56 AM.