View Full Version : Access DateDiff


PamJ
06-15-2011, 04:45 AM
I am a 57yrs old female who have been working on computers since I was 16, but only have basic knowledge Access.
I have a question to ask?
I am using Access 2007 and within the database table I have 2 columns with dates in - Assessment Date and Start Date and I need to find the difference between these two dates in days..
I have a query setup which includes these two columns along with 3 other columns from the table.
I have looked at the Access help and think I can do this using DateDiff, but however I try I cannot get the formula correct. Can anyone help me please? If you can help please keep the teminology simple!!!
Regards PamJ

pbaldy
06-15-2011, 05:33 AM
What have you tried? I'd expect something like

DateDiff("d", [Assessment Date], [Start Date])

boblarson
06-15-2011, 06:07 AM
What have you tried? I'd expect something like

DateDiff("d", [Assessment Date], [Start Date])
Paul - wouldn't that be

DateDiff("d", [Start Date], [Assessment Date])

with Assessment Date as the last argument? I'm assuming that you would have something like an employee start date and then their assessment date. So the earlier date should be first, wouldn't it? Or else you'd end up with a negative value.

PamJ
06-15-2011, 06:08 AM
Hi John - I missed the "d" out and now I have tried your offer and it works - many thanks for your quick help in this.

Regards

Pam

pbaldy
06-15-2011, 12:39 PM
Not sure who John is but I'm sure he was happy to help. :p

Bob: You could be right, I didn't really pay attention. My goal was to get the formula working. Easy enough for the OP to flip the dates if they got a negative result once it worked without error.

boblarson
06-15-2011, 01:28 PM
Not sure who John is but I'm sure he was happy to help. :p


RIDDLE: What do you get when you cross Paul with Bob

ANSWER: A toilet (john, get it :D :D)

gemma-the-husky
06-15-2011, 02:42 PM
pam - you can just take dates away, without bothering with datediff

daysdiff = enddate - startdate


if the dates have a time element, there may (only may) be a 1 day rounding error, but if they are just dates, this works fine.