By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,027 Members | 1,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,027 IT Pros & Developers. It's quick & easy.

Using Datediff in an update query

P: 1
I was trying to use the datediff function in the Update query and I added the following on the upate to field
: Datediff("d", [SentDate],[Recievedate]

where Sentdate: is a date stored in a table called cycle_table
Receievedate: is a date stored in a table called cycle_table
and I want to find the datediff in days
but I do not get the output I am expecting.
Sep 9 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,532
I think the you're trying to do something the Update Query wasn't really designed for, which is running a calculation! What you need is a standard query with a Calculated Field. You didn't give the name of the field that holds the desired rsults, so I'll call it DiffInDays.

Instead of an update query, do this:
Make a standard query with whatever you need in it.
In a blank field name type in:

Expand|Select|Wrap|Line Numbers
  1. DiffInDays: DateDiff("d",[SentDate],[RecieveDate])
Run the query. DiffInDays will now hold the info you want. Now, wherever you want this info to show (table, report) simply include this calculated field. If you base your form on this query the days will be calculated every time you open the form.

Note: I spelled your field as you had it in your post RecieveDate, which is misspelled. If this was a typo on your part in the post correct it so that both field in table and field in the datediff calculation are spelled the same way!

Good Luck and Welcome to TheScripts!

Linq ;0)>
Sep 9 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.