Date() Problem in Query

J

JBad

I have to retrieve a list of people whose passports have expired. I have the
list in the access database. Im trying to write a query to filter out those
ppl whose passport has expired since last 30 days from current date and also
those ppl whose passports would be expiring in the next 30 days from current
date. I cant seem to get the data types in dates to match. Can any one help
out please? the passport expiry dates are in the format mm/dd/yyyy and so is
the system date (under regional settings). Im trying to use date() /
formatdate() / cdate() but cant work it out...help!

Tanks..
 
R

Rick Brandt

JBad said:
I have to retrieve a list of people whose passports have expired. I
have the list in the access database. Im trying to write a query to
filter out those ppl whose passport has expired since last 30 days
from current date and also those ppl whose passports would be
expiring in the next 30 days from current date. I cant seem to get
the data types in dates to match. Can any one help out please? the
passport expiry dates are in the format mm/dd/yyyy and so is the
system date (under regional settings). Im trying to use date() /
formatdate() / cdate() but cant work it out...help!

Tanks..

SELECT *
FROM TableName
WHERE ExpiredDate >= DateAdd("d", -30, Date())
AND ExpiredDate < DateAdd("d", 31, Date())

With DateTime DataTypes formatting has absolutely nothing to do with
anything other than affecting visual display. A date is a date is a date.
 
J

JBad

Dearest Rick

No wonder u r Access MVP my friend !
It worked beautifully.....thx a million..

Acutally, im kinda new to access n stuff...so if u dnt mind, cud i bother u
on your id ([email protected]) with some other titbit probs i come across ?

thanx in advance ...

jb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top