On Mon, 05 Nov 2007 20:56:35 -0600, Lillian <(E-Mail Removed)> wrote:
>I receive a table from the main office and it has a Date of Birth field that
>is formated text and as yyyy/mm/dd. How do I make a query field as a real
>date and time format as mm/dd/yyyy and filter for all ages less than 25
>years old?
>
>I have this for a criteria but I don't have a real date format for the DOB
>field.
>
><=DateAdd("yyyy",-25,Date())
Either convert the criterion to a text string matching your text date (which
is fortunately of a form that is chronological):
<= Format(DateAdd("yyyy", -25, Date()), "yyyy/mm/dd")
or convert the text date to a real Date/Time field:
CDate([Date of Birth])
and omit the Format expression from your criterion.
The first option will have better performance if the table is large and the
field is indexed.
Your best bet would be to add a genuine date/time field to the table and run
an update query to populate it using CDate().
John W. Vinson [MVP]
|