Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 date problem

Author  Topic 

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-02-16 : 10:18:26
i'm scheduled a dts package to run every tuesday at noon. i need to modify my sp to select only records that have a certain date field set to the previous sunday. for example, if i were to run this dts package this tuesday, here is what i would want the sp to run:

select * from locations
where sap not in
(select sap from units where promoid=1 and reportingdate='2/15/2004')

how can i come up with the correct address every time this runs?

nr
SQLTeam MVY

12543 Posts

Posted - 2004-02-16 : 10:24:07
Might depend on your datefirst but

dateadd(dd,datepart(dw,getdate()) * -1 + 1, gedate())

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-02-17 : 21:16:32
This might do the trick also:

...and DATEDIFF(dd, reportingdate, GETDATE()) = 3

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page
   

- Advertisement -