dbTalk Databases Forums  

Problem with numeric parameter in DATEADD with DTS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Problem with numeric parameter in DATEADD with DTS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Problem with numeric parameter in DATEADD with DTS - 05-29-2006 , 12:29 PM






I am trying to construct a DTS task which will purge data that is more
than X months old.
So, I have a line in my query that looks like this:
DELETE...
WHERE [dateObj] < DATEADD (month,?,getDate())
I am trying to use a parameter so I can simply set a Global variable to
determine the number of months back I want to purge. I triedsetting the
global variable to an Int, to an Integer, I keep getting this error:
Error Description: Deferred prepare could not be completed.
Statement(s) could not be prepared.
Argument data type datetime is invalid for argument 2 of dateadd
function.

What gives? I'm not trying to use a datetime, I'm trying to use a
number. I have -6 programmed in as the value of the variable
monthsBack.

Any clue what I'm doing wrong?


Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default Re: Problem with numeric parameter in DATEADD with DTS - 05-29-2006 , 12:38 PM






I seem to have solved the problem with this modification:
WHERE [dateObj] < DATEADD(month,CONVERT(int,?),getDate())

I'm still not sure why I had to convert the variable to an int if it
was an int in the first place.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.