Results 1 to 10 of 10

Thread: Calculations

  1. #1
    Join Date
    Feb 2004
    Posts
    41

    Unanswered: Calculations

    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. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    how about cheating?

    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
    currently using SS 2008R2

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


    Hours: datediff("h", [date_start] , [date_return] )
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740


    thanks rudy!
    currently using SS 2008R2

  5. #5
    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. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    where are you coding it? it works fine in a query, but in a query, you would not use hours:
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  7. #7
    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. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you have datetimes stored as euros??!!

    can we see this query of yours, perhaps?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    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. #10
    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
    currently using SS 2008R2

Posting Permissions

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