Date Expression

G

Guest

I need to add criteria to a query field so that the only records shown are
those for which 14 days have past from a date in a specific field. The
expression I am using keeps giving me a type mismatch error. How can I
arrange this expression to work properly:

CDate(DateAdd("d",14,"Date Field")) >= Date()
 
T

Tom Ellison

Dear Candace:

A reference to a column name, except for certain special functions, would
not be in double quotes. Since yours contains a space, put it in square
brackets:

DateAdd("d",14,[Date Field]) >= Date()

DateAdd returns a date, so you don't need to convert it with CDate().

Does this help?

Tom Ellison
 
M

[MVP] S.Clark

Perhaps the space in the field name is causing a problem. Adding the square
brackets may help.

CDate(DateAdd("d",14,"[Date Field]")) >= Date()

FWIW, you can simplify this greatly with

WHERE [Date Field] + 14 >= Date()
 

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