whatswrong?

G

Guest

does any one see anything wrong with this? I'm trying to select all records
in which it is only 30 days untill the date entered in column nextcpr. i use
format mm/dd/yyyy. it must always select the records 30 days or less,
greater than the current date.
"SELECT * FROM login WHERE nextcpr <= #"& DateAdd("d", 30, Now()) &"#"
thanks in advance for your help!
 
R

Roger Carlson

Well, you don't say what you are getting from this query. At first glance
though, I would use Date() rather than Now(). Now() will include the time
and this may affect the outcome of the query.
 
T

TC

On the face of it, your test will select all records where nextcpr is set to
a non-null date which is less than or equal to today's date plus 30 days.
So, for example, it might select records with dates 10 years ago. (10 years
ago is <= today + 30 days) is that what you want?

Also, It is dangerous to use the #...# format for dates unless you
explicitly format the date into mm/dd/yyyy format within the statement. Try:

nextcpr <= #"& Format$ (DateAdd("d", 30, Date()), "mm/dd/yyyy") & "#"

HTH,
TC
 

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

Top