Solved

Access query - number of days between 2 datese

Posted on 2016-09-07
5
40 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 48

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 21
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 21
ID: 41788780
hi Patrick! ... hence my comment too ;)
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

729 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