A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Convert time to number



 
 
Thread Tools Display Modes
  #1  
Old August 29th, 2008, 06:10 PM posted to microsoft.public.access.forms
houstonthai
external usenet poster
 
Posts: 2
Default Convert time to number

I have 2 Fields [TimeIn],[TimeOut]. I used the [TimeOut]-[TimeIn] the answer
come out Ok. [18:25].Now I want to Multiply [18:25]*[$23.15] answer is Err.
Please advice me how to do it, I am new in the Access.
  #2  
Old August 29th, 2008, 06:51 PM posted to microsoft.public.access.forms
Golfinray
external usenet poster
 
Posts: 1,597
Default Convert time to number

Use the Datediff command in your query criteria. Datediff("d",[time in],[time
out])
The "d" will give you the answer in days,. If you want it in minutes, I
think it is either m or mm.

"houstonthai" wrote:

I have 2 Fields [TimeIn],[TimeOut]. I used the [TimeOut]-[TimeIn] the answer
come out Ok. [18:25].Now I want to Multiply [18:25]*[$23.15] answer is Err.
Please advice me how to do it, I am new in the Access.

  #3  
Old August 29th, 2008, 07:00 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Convert time to number

On Fri, 29 Aug 2008 10:10:28 -0700, houstonthai
wrote:

I have 2 Fields [TimeIn],[TimeOut]. I used the [TimeOut]-[TimeIn] the answer
come out Ok. [18:25].Now I want to Multiply [18:25]*[$23.15] answer is Err.
Please advice me how to do it, I am new in the Access.


Is that $23.15 per hour, or per minute?

In either case, an Access Date/Time value is a number - a count of days and
fractions of a day since midnight, December 30, 1899. It's really not suitable
for durations. I'd use the DateDiff function to calculate the number of
minutes as an integer:

DateDiff("n", [TimeIn], [TimeOut]) * 23.15

Divide by 60 if that number is per hour. Your expression had the $23.15 in
square brackets so Access would assume that it is a (rather strange) fieldname
- DON'T use brackets to surround values; they are used for the *names* of
fields, tables, forms etc. but not for numeric values.
--

John W. Vinson [MVP]
  #4  
Old August 29th, 2008, 07:07 PM posted to microsoft.public.access.forms
Ryan
external usenet poster
 
Posts: 551
Default Convert time to number

You need to use the name of the result. It would look like this.

TotalTime:[TimeOut]-[TimeIn]
TotalAmount:[TotalTime]*23.15
--
Please remember to mark this post as answered if this solves your problem.


"houstonthai" wrote:

I have 2 Fields [TimeIn],[TimeOut]. I used the [TimeOut]-[TimeIn] the answer
come out Ok. [18:25].Now I want to Multiply [18:25]*[$23.15] answer is Err.
Please advice me how to do it, I am new in the Access.

  #5  
Old August 29th, 2008, 09:12 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Convert time to number

On Fri, 29 Aug 2008 10:51:00 -0700, Golfinray
wrote:

Use the Datediff command in your query criteria. Datediff("d",[time in],[time
out])
The "d" will give you the answer in days,. If you want it in minutes, I
think it is either m or mm.


Actually "m" is Months; "n" is miNutes.
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.