Calc date problem

G

Gerard

I have an inherited Db with a query that calcs a date via dateadd: -

DateAdd("yyyy",[Term],(DateAdd("d",[Adjustment],[EmployStartDate])))

This works fine but I can not seem to put a criteria against this calc
field and keep getting data type mismatch error.

I’ve tried: -
#31/12/2006#

Cdate(31/12/2006)

All help/suggestions welcome.

Cheers – Phil
 
R

Rick Brandt

Gerard said:
I have an inherited Db with a query that calcs a date via dateadd: -

DateAdd("yyyy",[Term],(DateAdd("d",[Adjustment],[EmployStartDate])))

This works fine but I can not seem to put a criteria against this calc
field and keep getting data type mismatch error.

I’ve tried: -
#31/12/2006#

Cdate(31/12/2006)

All help/suggestions welcome.

Cheers – Phil

Date literals in Access queries need to be in either US formats (mm/dd/yy or
mm/dd/yyyy), or in ISO format (yyyy-mm-dd), or in a format where the month uses
characters (mmm-dd-yyyy). The DateSerial() should have worked for you though.

Are you sure that the DateAdd() expression you posted is the only thing in that
field? There is nothing that might be converting the type to a string (like
Format())?
 
G

Gerard

Rick said:
Gerard said:
I have an inherited Db with a query that calcs a date via dateadd: -

DateAdd("yyyy",[Term],(DateAdd("d",[Adjustment],[EmployStartDate])))

This works fine but I can not seem to put a criteria against this calc
field and keep getting data type mismatch error.

I’ve tried: -

#31/12/2006#

Cdate(31/12/2006)

All help/suggestions welcome.

Cheers – Phil


Date literals in Access queries need to be in either US formats (mm/dd/yy or
mm/dd/yyyy), or in ISO format (yyyy-mm-dd), or in a format where the month uses
characters (mmm-dd-yyyy). The DateSerial() should have worked for you though.

Are you sure that the DateAdd() expression you posted is the only thing in that
field? There is nothing that might be converting the type to a string (like
Format())?
Rick - no the above is a direct copy of formula in query and yes thought
I might have to use US format as I'm in Australia so our date format is
different.

Dateserial has worked for me before on tricky date calcs??
 
R

Rick Brandt

Gerard said:
Rick - no the above is a direct copy of formula in query and yes
thought I might have to use US format as I'm in Australia so our date
format is different.

Dateserial has worked for me before on tricky date calcs??

Well the help file does state that both DateAdd() and DateSerial() return a
Variant with sub-type of date so perhaps you do need to wrap the DateAdd()
in a CDate() function.

You might also be able to specify that expression as a DateTime type in the
parameters box to solve the problem.
 

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