like operator

S

seth

i'm learning more about queries and understand how to use text as part of a
phrase using * and how to use like operator and using [ ] to prompt for
input. is there anyway to combine it?

what i wanted to attempt is to prompt for input, and use like operator to
find whatever what put in in that field.

for example, if i have a date/time field (unfortunately both are in the same
field) i want to prompt for the date, but query everything that it contains.
so if the field is 5/5/2005 12:00:00 i want to be able to just type 5/5/2005
when running the query and show all records that contain that text, no
matter what time follows it.

is this possible?
or is there a way to get around it?
tia
 
N

ngan

Try the Format function....Format(fieldname, "Short Date")...look up the
format function in your module help section.
 
J

John Vinson

i'm learning more about queries and understand how to use text as part of a
phrase using * and how to use like operator and using [ ] to prompt for
input. is there anyway to combine it?

what i wanted to attempt is to prompt for input, and use like operator to
find whatever what put in in that field.

Use

LIKE "*" & [Enter term:] & "*"

on the criteria line.
for example, if i have a date/time field (unfortunately both are in the same
field) i want to prompt for the date, but query everything that it contains.
so if the field is 5/5/2005 12:00:00 i want to be able to just type 5/5/2005
when running the query and show all records that contain that text, no
matter what time follows it.

The above advice applies to TEXT fields (it's still useful there
though so I'm leaving it in!) but a date/time field *IS NOT TEXT*.
Internally, it's stored as a Double Float count of days and fractions
of a day (times) since midnight, December 30, 1899.

To get all records for a given day, regardless of the time, you can
use a criterion
= [Enter date:] AND < DateAdd("d", 1, [Enter date:])

Access will only prompt you once if the parameter is exactly the same
in both instances.

John W. Vinson[MVP]
 
Top