English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

In a table, I have two fields (StartDate and EndDate). Whenever a user inputs the dates for those fields, I want a field I labelled "Est_Hours" to automatically populate the hours.

I have tried using the DateDiff function, but I am not sure if I would do that in the "Default Value" or "Value Validation" areas. Thanks in advance.

2007-01-24 07:29:44 · 2 answers · asked by ninapanama 3 in Computers & Internet Programming & Design

2 answers

Use a QUERY. Build the Query in DESIGN VIEW. You can add the two date fields you want to find the difference between and then create a new field that shows the difference by doing the following:

Est_hours:DateDiff(StartDate,EndDate,"s") - DO NOT CREATE THE FIELD IN THE TABLE VIEW.

2007-01-24 07:54:11 · answer #1 · answered by Richard H 7 · 1 0

Yes, listen to Richard H. Create a brand new spanking query with the above fields you mentioned. Then add a third that has your datediff function using those 2 fields. Like so :

SELECT StartDate, EndDate, DateDiff("h", StartDate, EndDate) AS Est_Hours FROM [TABLENAME]

Pretty slick. Good luck!

2007-01-24 17:13:32 · answer #2 · answered by Special Ed 5 · 2 0

fedest.com, questions and answers