How do I use DateDiff to calculate costs?

zebra

Registered User.
Local time
Today, 20:24
Joined
Apr 23, 2009
Messages
20
Hi,
In my bookings system you select a number of Units and a start and end booking time. I need to calculate the cost of each Unit for the booking as well as a total cost for all Units in the booking.

The information is stored in two tables: a bookings table called tblHourPeriod with the resources used and fromTime and thruTime fields. A second table called tblUnit has the list of resources and their rate card costs (per hour). I need the query to calculate the difference between fromTime and thruTime and then multiply this by the rate card. Any ideas how to do this?

Thanks,
Z
 
From the help:
Code:
DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

The DateDiff function syntax has these named arguments:

Part Description 
interval Required. String expression that is the interval of time you use to calculate the difference between date1 and date2. 
date1, date2 Required; Variant (Date). Two dates you want to use in the calculation. 
firstdayofweek Optional. A constant that specifies the first day of the week. If not specified, Sunday is assumed. 
firstweekofyear Optional. A constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs. 

Settings

The interval argument has these settings:

Setting Description 
yyyy Year 
q Quarter 
m Month 
y Day of year 
d Day 
w Weekday 
ww Week 
h Hour 
n Minute 
s Second

Though its probably easier if you just look it up in the help :D
 
Thanks, yes I found that but I was wondering where I actually put that code?
 
Anywhere you want this calculation to be done... Query/Form/Report/code....
 
thanks. I was being a bit slow but I've now done it. muchos gracias!
 

Users who are viewing this thread

Back
Top Bottom