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

days between two dates

P: n/a
What is formula that get days between two dates?
Npr: 11.03.1998 1.7.2005

Thank you, Mojca
Nov 13 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
If dates are in Field1 and field2 and provided both of these are datetime
datatype containing just dates and no time values then you can just take
one from the other.

Result = Field1-field2

Peter
Mojca previously wrote:
What is formula that get days between two dates?
Npr: 11.03.1998 1.7.2005

Thank you, Mojca


Nov 13 '05 #2

P: n/a
On 6 Jul 2004 01:23:27 -0700, ki********@yahoo.com (Mojca) wrote:

I prefer to always use the DateDiff function.
-Tom.
What is formula that get days between two dates?
Npr: 11.03.1998 1.7.2005

Thank you, Mojca


Nov 13 '05 #3

P: n/a
Ray
ki********@yahoo.com (Mojca) wrote in message news:<d5**************************@posting.google. com>...
What is formula that get days between two dates?
Npr: 11.03.1998 ? 1.7.2005

Thank you, Mojca


Hello Mojca,

My first question is, how many fields are being used for
your dates?

If one field, then:

(This expression uses the exact dates in the criteria)

Between #11/03/1998# and #01/07/2005#

(The following expression will pop up two windows that ask for
your starting and ending dates]

Or Between [Enter Starting Date] and [Enter Ending Date]
If two fields, the check out the DateDiff function.

Regards,

Ray
Nov 13 '05 #4

P: n/a
Tom van Stiphout <no*************@cox.net> wrote in
news:9f********************************@4ax.com:
On 6 Jul 2004 01:23:27 -0700, ki********@yahoo.com (Mojca) wrote:

What is formula that get days between two dates?
Npr: 11.03.1998 1.7.2005


I prefer to always use the DateDiff function.


When you're calculating days, what's the advantage of DateDiff()
over simply subtracting the dates?

If you assume that your values have no time component (I seldom use
date fields with time components myself, so that's a safe assumption
in my own work), then, because the date value is stored in the
integer value of the date, subtracting the earlier from the later
will always return an accurate number of days between the two dates.

Right?

DateDiff() is indispensable for calculating differences in weeks or
months or quarters or years, though.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #5

P: n/a
On Tue, 06 Jul 2004 16:33:11 GMT, "David W. Fenton"
<dX********@bway.net.invalid> wrote:

It's just a matter of being consistent and explicit.
As a former C++ programmer I think: that's a lot of trouble to support
date math like A-B: I have to overload the - operator. If I'm smart
I'll implement it by calling DateDiff. As a beginner programmer I can
never remember whether A-B only works for days, or seconds, or years?
What's so special about days anyway to warrant that exception? If I'm
MSFT and rewritinng the language like we do every couple of years,
perhaps I'll just yank that feature altogether because it's
inconsistent. (I haven't checked if A-B for dates is still supported
in .NET, but they did yank other inconsistent features).

-Tom.

Tom van Stiphout <no*************@cox.net> wrote in
news:9f********************************@4ax.com :
On 6 Jul 2004 01:23:27 -0700, ki********@yahoo.com (Mojca) wrote:

What is formula that get days between two dates?
Npr: 11.03.1998 1.7.2005


I prefer to always use the DateDiff function.


When you're calculating days, what's the advantage of DateDiff()
over simply subtracting the dates?

If you assume that your values have no time component (I seldom use
date fields with time components myself, so that's a safe assumption
in my own work), then, because the date value is stored in the
integer value of the date, subtracting the earlier from the later
will always return an accurate number of days between the two dates.

Right?

DateDiff() is indispensable for calculating differences in weeks or
months or quarters or years, though.


Nov 13 '05 #6

P: n/a
ra*****@excite.com (Ray) wrote in message news:<20**************************@posting.google. com>...
ki********@yahoo.com (Mojca) wrote in message news:<d5**************************@posting.google. com>...
What is formula that get days between two dates?
Npr: 11.03.1998 ? 1.7.2005

Thank you, Mojca
Hello Mojca,

(The following expression will pop up two windows that ask for
your starting and ending dates]

Or Between [Enter Starting Date] and [Enter Ending Date]


Although, as you have discovered, this technique will produce results,
most Access programmers would consider this technique to be somewhat,
err.. Neanderthal. They would rather seduce the cavewomen than bonk
them on the head (How's that for anachronism? :-)). The bonk refers
to the somewhat brutal Query interface and the seduction refers to a
more visually attractive, friendly and possibly errorproof Form. I
once used an InputBox to get a Report title so I am guilty of this
also, but I'm trying to become civilized. It's like using
Command1_Click(). It works, but style points are lost. Of course,
programmers like to nit-pick about minutiae like techniques that take
nanoseconds off execution time so don't take every suggestion too
seriously.

James A. Fortune
Nov 13 '05 #7

P: n/a
Tom van Stiphout <no*************@cox.net> wrote in
news:ll********************************@4ax.com:
It's just a matter of being consistent and explicit.
As a former C++ programmer I think: that's a lot of trouble to
support date math like A-B: I have to overload the - operator. If
I'm smart I'll implement it by calling DateDiff. As a beginner
programmer I can never remember whether A-B only works for days,
or seconds, or years? What's so special about days anyway to
warrant that exception? If I'm MSFT and rewritinng the language
like we do every couple of years, perhaps I'll just yank that
feature altogether because it's inconsistent. (I haven't checked
if A-B for dates is still supported in .NET, but they did yank
other inconsistent features).


I don't know how anyone could work with dates at all in Access and
not keep track of exactly why A-B works for days -- it's part and
parcel of the basic definition of how dates are stored (the integer
part of the double is the number of days since the starting point,
which I forget, because it's never important to me).

MS could not "yank" this feature unless they changed the way dates
are stored in Jet and VBA.

So, I still don't see a justification for using DateDiff() to get
number of days.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8

P: n/a
"David W. Fenton" <dX********@bway.net.invalid> wrote in
news:Xn**********************************@24.168.1 28.86:
Tom van Stiphout <no*************@cox.net> wrote in
news:ll********************************@4ax.com:
It's just a matter of being consistent and explicit.
As a former C++ programmer I think: that's a lot of trouble to
support date math like A-B: I have to overload the - operator. If
I'm smart I'll implement it by calling DateDiff. As a beginner
programmer I can never remember whether A-B only works for days,
or seconds, or years? What's so special about days anyway to
warrant that exception? If I'm MSFT and rewritinng the language
like we do every couple of years, perhaps I'll just yank that
feature altogether because it's inconsistent. (I haven't checked
if A-B for dates is still supported in .NET, but they did yank
other inconsistent features).
I don't know how anyone could work with dates at all in Access and
not keep track of exactly why A-B works for days -- it's part and
parcel of the basic definition of how dates are stored (the integer
part of the double is the number of days since the starting point,
which I forget, because it's never important to me).


ROFL! Did you READ this paragraph before you clicked "Send"?
MS could not "yank" this feature unless they changed the way dates
are stored in Jet and VBA.
What if they stopped evil type coercion? ("Tis a consummation
devoutly to be wished")! Do you think VBA subtracts the Dates, or first
converts the Dates to Doubles and then subtracts?
So, I still don't see a justification for using DateDiff() to get
number of days.


Date - OtherDate returns a Double.
DateDiff(interval, date1, date2) returns a Long.
What else?

--
Lyle
--
use iso date format: yyyy-mm-dd
http://www.w3.org/QA/Tips/iso-date
--
The e-mail address isn't, but you could use it to find one.
Nov 13 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.