Solved

Access query - number of days between 2 datese

Posted on 2016-09-07
5
29 Views
Last Modified: 2016-10-03
Hi,

I would like to know, in a query, how can I calculate the numbers of days between 2 dates

Thanks
0
Comment
Question by:Karl001
  • 2
5 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 41788169
You can use the DateDiff() function:

DaysBetween:DateDiff("d", [StartDate], [EndDate])

Note that for consecutive days this will return the value 1.  Basically, this takes the integer portion of the [EndDate] and subtracts the integer portion of [StartDate].
0
 
LVL 19
ID: 41788238
adding on: if date also contains a time component, you can test this and subtract one day if time for comparison date is greater than time for the first date since a full day(s) will not have passed.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 41788648
Depends on what you need to know.  For example, as Dale noted, you could use DateDiff, but what that delivers is the number of time period boundaries between two date/time values.

For example, consider these two values:

2016-09-05 23:59:59
2016-09-07 00:00:00

DateDiff using "d" for the interval length, would return two.  In terms of true time elapsed, it's one day plus one second.

So, what specifically are you trying to calculate?
0
 
LVL 19
ID: 41788780
hi Patrick! ... hence my comment too ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now