Date query

  • Thread starter Thread starter Iago
  • Start date Start date
I

Iago

I have a table which contains a field called "DUEDATE", data type is
DATE/TIME, formatted as LONGDATE. I use it to enter in dates when projects
are due.
How can I write a query which returns "DUEDATE" items for the current date.
Example: Today is January 21, 2010 and I want to retrieve everything from
the table with "DUEDATE" of january 21,2010.
 
If you only store the date part and only want to return records where the
DueDate is the current date, set the criteria under DueDate to:
=Date()

Duane Hookom
MS Access MVP
 
I have a table which contains a field called "DUEDATE", data type is
DATE/TIME, formatted as LONGDATE. I use it to enter in dates when projects
are due.

The format is irrelevant - it only controls how the data is displayed. A more
important question is what are you storing in the field? Does DUEDATE contain
values like just 1/21/2010, or 1/21/2010 1:00PM?

An Access Date/Time values is actually stored as a Double Float number, a
count of days and fractions of a day (times) from a startpoint. The format
controls how that number is displayed.
How can I write a query which returns "DUEDATE" items for the current date.
Example: Today is January 21, 2010 and I want to retrieve everything from
the table with "DUEDATE" of january 21,2010.

If you want to search for just today's date, AND the field contains no time
portion, just use

=Date()

in the criteria line. If the field does contain times, use
= Date() AND < Date()+1

to get all values from midnight last night up to just before midnight tonight.

To get data for a specific date use a criterion such as

#1/21/2010#

(the # marks delimit date values); better, use a Parameter Query. Post back if
you'ld like more info on these.
 
Back
Top