Calculating the difference

  • Thread starter chris0309 via AccessMonster.com
  • Start date
C

chris0309 via AccessMonster.com

I have two columns within a table, the first contains "20/03/2009 11:00:00"
and the second contains "21/03/2009 12:00:00". Is there a way to calculate
the difference within a query?

Thanks for any help.
 
J

John Spencer

Assuming that the two fields (columns) are DateTime fields, you can
calculate the difference using the DateDiff function.

DateDiff("n",[DateOne],[DateTwo])

The first argument specifies the interval
d = day
n = hour
s = second
m = month
yyyy = year
q = quarter

You need to be aware that the datediff counts the transitions from one
value to the next.

For example using
December 31 2009 23:59:59 to January 1 2010 00:01:34
The transitions are
1 day
1 month
1 year
1 hour
2 minutes
94 seconds

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
S

Stefan Hoffmann

hi Chris,
I have two columns within a table, the first contains "20/03/2009 11:00:00"
and the second contains "21/03/2009 12:00:00". Is there a way to calculate
the difference within a query?
Take a look at the OH: DateDiff()


mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top