473,490 Members | 2,635 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Comparison Operator for Date


Hello

In VBA I need to count records from an Offers table, that were created
beetwen 2 dates (strDate1 and strDate2).

Using the DCount as follow gives me strange results: records that were
created ON strDate1 are taken in account while records that were created
ON strDate2 are not. Records that were created before strDate2 are taken
in account.

In others words, it works fine unless that it doesn't take the = part of
the second operator.

DCount("*", "Offers", "([OfferDate] >= #" & strDate1 & "#) AND (#" &
strDate2 & "# >= [OfferDate])")

Any idea? Thanks in advance!

nectar
--
Posted via http://dbforums.com
Nov 12 '05 #1
3 7316
and there's always BETWEEN

"nectar" <me*********@dbforums.com> wrote in message
news:33****************@dbforums.com...

Hello

In VBA I need to count records from an Offers table, that were created
beetwen 2 dates (strDate1 and strDate2).

Using the DCount as follow gives me strange results: records that were
created ON strDate1 are taken in account while records that were created
ON strDate2 are not. Records that were created before strDate2 are taken
in account.

In others words, it works fine unless that it doesn't take the = part of
the second operator.

DCount("*", "Offers", "([OfferDate] >= #" & strDate1 & "#) AND (#" &
strDate2 & "# >= [OfferDate])")

Any idea? Thanks in advance!

nectar
--
Posted via http://dbforums.com

Nov 12 '05 #2
Your values probably have time in them as well as the date (are you using
the Now() function to populate them?) Date/Time values are stored as 8 byte
floating point numbers, where the integer part represents the date as the
number of days relative to 30 Dec, 1899, and the decimal part represents the
time as a fraction of a day. If all you specific is a date, it's assumed to
be midnight of that day, and any records for that day which include a time
will be greater than just the date.

You can use the DateValue function to remove the time from your values, or
you can just use one day higher in your comparison.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"nectar" <me*********@dbforums.com> wrote in message
news:33****************@dbforums.com...

Hello

In VBA I need to count records from an Offers table, that were created
beetwen 2 dates (strDate1 and strDate2).

Using the DCount as follow gives me strange results: records that were
created ON strDate1 are taken in account while records that were created
ON strDate2 are not. Records that were created before strDate2 are taken
in account.

In others words, it works fine unless that it doesn't take the = part of
the second operator.

DCount("*", "Offers", "([OfferDate] >= #" & strDate1 & "#) AND (#" &
strDate2 & "# >= [OfferDate])")

Any idea? Thanks in advance!

nectar
--
Posted via http://dbforums.com

Nov 12 '05 #3

MIKE, thanks very much for your input.

Here is my answers:

- strDate comes from a String field from a form. Before using it in the
DCount I do strDate1 = Format(Me!Date1, "mm/dd/yyyy"). I tested it is
a date and got back a true...

- Actually it's >= AND <=. Just that the memebers of the inequality
are inverse

- I already tried BETWEEN and it didn't work.
--
Posted via http://dbforums.com
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1605
by: Travel Jadoo | last post by:
Hi, I used the & operator to evaluate whether a certain day would match the days of operation of a flight. In v7.2.3 I could use the following to do that: select 127::smallint &...
4
7167
by: Peter Kirk | last post by:
Hi I am looking at some code which in many places performs string comparison using == instead of Equals. Am I right in assuming that this will in fact work "as expected" when it is strings...
37
2759
by: spam.noam | last post by:
Hello, Guido has decided, in python-dev, that in Py3K the id-based order comparisons will be dropped. This means that, for example, "{} < " will raise a TypeError instead of the current...
3
10210
by: Tiya | last post by:
Hi there !!! I would like to know how to compare dates in javascript. var sdate = new Date(theform.SubmissionDate.value); var odate = new Date(theform.StartDate.value); var todaysdate = new...
2
6750
by: eastern_strider | last post by:
I'm running into problems about defining a comparison function for a map which has a user defined key. For example: class Key { public: string name; int number; Key (na, nu) : name (na),...
5
3879
by: fade | last post by:
Good afternoon, I need some advice on the following: I've got a class that has a member std::vector<CStringm_vFileName and a member CString m_path; The vector contains a bunch of filenames with...
1
1885
by: saundap | last post by:
Hi, Access 2000, Windows 2000 Professional I have a form I've developed that is designed for those not familiar with access and its query tool. WIthin a subform in the form there is presented...
11
3517
by: Andrus | last post by:
I created dynamic extension methods for <= and < SQL comparison operators: public static IQueryable<TLessThanOrEqual<T>(this IQueryable<Tsource, string property, object value); public static...
2
3005
by: puzzlecracker | last post by:
Unlike C++, in Csharp you're only allowed to compare a generic type T with null, if the method it's passed in not implementing IComparable<Tor , IEquatable<T(still don't know why we need these...
0
7112
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.