1. Registered User
Join Date
Feb 2004
Posts
41

Hey,
Im doing a car rental system and the cost of the car is done per hour! I have the following query set up and working:

Hours: (((([date_return]-[date_start])-2)*24)+[No_Of_Hours_Start]+ [No_Of_Hours_End])*[Vehicle_Detail.hire_rate]

But i have to manually enter the no of hours in the first day and the last day that the person has the car. I want the user of the system (e.g person working for the car rental company) to be able to just enter the time they hire and return the car and for a query or something to enter the no of hours the renter has the car for on those days to the table from the form - Can Anyone help plz?!

2. Cavalier King Charles
Join Date
Dec 2002
Location
Préverenges, Switzerland
Posts
3,740

A's dates are double-precision floats: left of the decimal point is days (actually, days after #1/1/100#); right of the decimal point is fractional days.

dim Duration as double
Duration = DateTimeEnd - DateTimeStart

...gives you Duration as days.fractionalDays

a bit of messing around should get all this into hours.
maybe it is as simple as Duration * 24 (but i didn't check it)

izy

3. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
um, sorry to butt in here, but what's wrong with datediff?

Hours: datediff("h", [date_start] , [date_return] )

4. Cavalier King Charles
Join Date
Dec 2002
Location
Préverenges, Switzerland
Posts
3,740

thanks rudy!

5. Registered User
Join Date
Feb 2004
Posts
41
Im afraid it keeps saying that it has an invalid dot, ! or parenthesis - but that syntax for the dafediff is right isnt it?!

6. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
where are you coding it? it works fine in a query, but in a query, you would not use hours:

7. Registered User
Join Date
Feb 2004
Posts
41
I tried it in a query but its returning the answer to me in Irish pounds but everything is set in euros?! beat that one!!!

8. SQL Consultant
Join Date
Apr 2002
Location
Posts
20,002
you have datetimes stored as euros??!!

can we see this query of yours, perhaps?

9. Registered User
Join Date
Feb 2004
Posts
41
Well no obviously not date times as euros but i mulitply the results i get from the query by the hire_rate which is in euros and its giving me an answer in pounds!!! this is what i have:

(DateDiff("h",[date_start],[date_return]))*[Vehicle_Detail.hire_rate]

10. Cavalier King Charles
Join Date
Dec 2002
Location
Préverenges, Switzerland
Posts
3,740
...its giving me an answer in pounds!!!
what is really happening?
you get the correct € amount calculated but with a £ stuck in front instead of €

...or the system is magically doing a currency conversion and actually producing a £ value.

i suspect the first ...which is a field format problem not a query or calculation problem.

izy

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•