Wrong Datatype in query

  • Follow


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
0
Reply Utf 2/22/2008 8:03:01 PM

On Fri, 22 Feb 2008 12:03:01 -0800, Alain wrote:

> 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));
 
-- 
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
0
Reply fredg 2/22/2008 8:25:11 PM


Alain -

Try removing the quotes around "Date()".

Bob

Alain wrote:
>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

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200802/1

0
Reply raskew 2/22/2008 8:39:24 PM

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" wrote:

> On Fri, 22 Feb 2008 12:03:01 -0800, Alain wrote:
> 
> > 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));
>  
> -- 
> Fred
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
> 
0
Reply Utf 2/22/2008 8:44:02 PM

3 Replies
302 Views

(page loaded in 0.469 seconds)

Similiar Articles:
















7/18/2012 7:38:52 AM


Reply: