Wrong Datatype in query

A

Alain

Hi to all,

I am getting a data type mismatch in the following query in the where
condition:

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,"Date()")
WHERE (((tblBudgetBr.MthToMth)=True));

If I run a normal select with the same criteria,it works fine, can anyone
tell me what is wrong here ??

TIA
 
F

fredg

Hi to all,

I am getting a data type mismatch in the following query in the where
condition:

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,"Date()")
WHERE (((tblBudgetBr.MthToMth)=True));

If I run a normal select with the same criteria,it works fine, can anyone
tell me what is wrong here ??

TIA

It shouldn't work fine anywhere.

Are you trying to add 2 years from today's date and store it in [To]?
Remove the quotes from around Date().

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,Date())
WHERE (((tblBudgetBr.MthToMth)=True));

Or are you trying to add 2 years to an existing date already stored
in [To]?

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,[To])
WHERE (((tblBudgetBr.MthToMth)=True));
 
R

raskew via AccessMonster.com

Alain -

Try removing the quotes around "Date()".

Bob
Hi to all,

I am getting a data type mismatch in the following query in the where
condition:

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,"Date()")
WHERE (((tblBudgetBr.MthToMth)=True));

If I run a normal select with the same criteria,it works fine, can anyone
tell me what is wrong here ??

TIA
 
A

Alain

Hi Fred,

I am trying to add 2 year to today's date in the [To] field, I did not
notice the quotes since I did it from the query design to save some typing.
Working fine without the quotes

Thanks

Alain


fredg said:
Hi to all,

I am getting a data type mismatch in the following query in the where
condition:

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,"Date()")
WHERE (((tblBudgetBr.MthToMth)=True));

If I run a normal select with the same criteria,it works fine, can anyone
tell me what is wrong here ??

TIA

It shouldn't work fine anywhere.

Are you trying to add 2 years from today's date and store it in [To]?
Remove the quotes from around Date().

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,Date())
WHERE (((tblBudgetBr.MthToMth)=True));

Or are you trying to add 2 years to an existing date already stored
in [To]?

UPDATE tblBudgetBr SET tblBudgetBr.[To] = DateAdd("yyyy",2,[To])
WHERE (((tblBudgetBr.MthToMth)=True));
 

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