Today() Function

  • Thread starter Thread starter Brian Corralejo
  • Start date Start date
B

Brian Corralejo

As I understand it, the TODAY function should behave
similarly to the NOW function. However, I get an error
when running a query containing that function. I enter the
following field in a query:
Today's Date: Today()
When I run the query I get an error of:
"Undefined function 'today' in expression."
(If I replace TODAY with NOW, the query works fine.)
Anything obvious I'm missing?
 
Brian Corralejo said:
As I understand it, the TODAY function should behave
similarly to the NOW function. However, I get an error
when running a query containing that function. I enter the
following field in a query:
Today's Date: Today()
When I run the query I get an error of:
"Undefined function 'today' in expression."
(If I replace TODAY with NOW, the query works fine.)
Anything obvious I'm missing?


Access 97 doesn't have this function. Unless it was added in one of the newer
versions it doesn't exist.
 
Rick Brandt said:
Access 97 doesn't have this function. Unless it was added in one of the newer
versions it doesn't exist.

I just noticed. Today() is an Excel function. That's why it doesn't work in Access.
 
I'm not aware of a Today() function in ACCESS (even 2002). As Rick says,
this is an EXCEL worksheet function that returns today's date.

What you want in ACCESS is the Date() function.
 
Brian said:
It's Access 2000.

My Access 2000 help clearly indicates that Today is a worksheet function and
describes its use in a "cell". That tells me it is an Excel function, not Access.
 
Thank you Ken and Rick.
You're right, the terms "cell" and "worksheet" should have
clued me in that it's not an Access function. However, in
my defense, the instructions for NOW()also refer
to "worksheet." And since it was Access Help and didn't
refer to Excel at all, blah blah blah...

Anyway, Date() gives me exactly what I was looking for -
today's date! Thanks much!
 
Also, you want to use extreme caution with mixing NOW() or DATE().

I seen some people use a default of NOW() for a date field. Note that NOW()
returns both date AND the time part. This time part will be stored in the
date field.

Given this fact, then all queries that you use for a given date will fail if
you use now, since the date value will also need a time part. Be VERY
careful with the use of NOW(), especially when you don't need it. I seen
some real mess made with this seemly small difference!

So, only use NOW() if you need to store both date and time (and be aware
that simple date conditions will NOT work on a field that has a now() time
in it).
 
For the records, there is a Today Method of the Calendar Control but for
Access VBA, the function you want is Date() for date-only or Now() for date
AND time.
 
Back
Top