dbTalk Databases Forums  

Dynamic date selection

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


Discuss Dynamic date selection in the microsoft.public.sqlserver.dts forum.



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

Default Dynamic date selection - 02-01-2005 , 10:33 AM






I have a DTS package, part of which does this:_

select * from database.tablename where ididat = 20050130

What I would like to do is replace the fixed date with a dynamic date, so I
don't have to edit it. I've tried combinations of DateAdd and GetDate() etc,
but to no avail.

I just can't get it to work. Badically, it needs to return the data from the
previous day.

Any help would be greatly appreciated.
Thx
Billy

Reply With Quote
  #2  
Old   
Sue Hoegemeier
 
Posts: n/a

Default Re: Dynamic date selection - 02-01-2005 , 02:38 PM






That's hard to say without knowing how your dates are stored
or what you need to do with the time portion and how that
needs to be handled. But DateAdd is what you would need to
do. Something along the lines of:
select *
from YourTable
where DateColumn = Dateadd(dd, -1, cast(convert(varchar(10),
GetDate(), 101) as Datetime))

-Sue

On Tue, 1 Feb 2005 08:33:04 -0800, "Billy"
<Billy (AT) discussions (DOT) microsoft.com> wrote:

Quote:
I have a DTS package, part of which does this:_

select * from database.tablename where ididat = 20050130

What I would like to do is replace the fixed date with a dynamic date, so I
don't have to edit it. I've tried combinations of DateAdd and GetDate() etc,
but to no avail.

I just can't get it to work. Badically, it needs to return the data from the
previous day.

Any help would be greatly appreciated.
Thx
Billy


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.