The problem probably isn't with Now(), but you still don't want to use that.
Now() returns date AND time ... instead, use Date() to get just the date
portion.
Access/Jet has but one temporal data type named DATETIME, which
*always* returns a time element (as an aid memoir, get into the habit
of always writing DATETIME values in full -- ISO 8601 if it's an
international forum, please). If the OP is using a NULL end date value
to indicate the period of the current state, it makes perfect sense to
use the current timestamp NOW() in place of NULL when querying the
table, time being a continuum and all.
I think the OP's issue is with time granules and time representation
of periods (closed-open, closed-closed, etc). Take the period:
[ #2007-07-23 09:00:00#, #2007-07-24 17:00:00#)
Say that this is taken to mean a two day stay in the OP's model.
Using DATEDIFF to calculate days always rounds down, so if I'm using
closed-closed representation (where both start and end dates falls
within the period; suits BETWEEN constructs) to model a two day stay
like this:
[ #2007-07-23 00:00:00#, #2007-07-24 23:59:59#]
then DATEDIFF will calculate this as
SELECT DATEDIFF('D', #2007-07-23 00:00:00#, #2007-07-24 23:59:59#)
returns 1 (day). In practice, I find I have to add one second (one of
the disadvantages of closed-closed representation).
If the smallest time granule in the OP's table is one day then perhaps
close-open representation (where the end date does not fall within the
period; suits Access/Jets floating point nature of DATETIME) is better
e.g. modelled as (note the closing parenthesis denoting an open end
date):
[ #2007-07-23 00:00:00#, #2007-07-25 00:00:00#)
SELECT DATEDIFF('D', #2007-07-23 00:00:00#, #2007-07-25 00:00:00#)
returns 2 (days).
I've never been comfortable with using closed-open representation,
because using #2007-07-25 00:00:00# to model #2007-07-24 17:00:00# is
non-intuitive for me.
Perhaps a better approach is to model the actual start dates and
'round' them as appropriate when calculating. Take this extreme
example:
[ #2007-07-23 23:59:59#, #2007-07-24 00:00:01#]
Frankly, I'd question whether a two second stay should be considered a
two day stay (!!) but here's how I'd do it:
SELECT
DATEADD('D', DATEDIFF('D', #1990-01-01 00:00:00#, #2007-07-23
23:59:59#), #1990-01-01 00:00:00#) AS start_date_rounded_down,
DATEADD('D', DATEDIFF('D', #1990-01-01 00:00:00#, #2007-07-24
00:00:01#), #1990-01-02 00:00:00#) AS end_date_rounded_up,
DATEDIFF('D', DATEADD('D', DATEDIFF('D', #1990-01-01 00:00:00#,
#2007-07-23 23:59:59#), #1990-01-01 00:00:00#),
DATEADD('D', DATEDIFF('D', #1990-01-01 00:00:00#, #2007-07-24
00:00:01#), #1990-01-02 00:00:00#)) AS interval_days_spanned
Jamie.
--