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
 Import/Export (DTS) and Replication (2000)
 Setting up date variables in a DTS package

Author  Topic 

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2006-03-15 : 11:50:19
Guys -

Dumb question, How do you guys have your VB script set in order to setup date global variables in a DTS package that would set let's say:

Date1 = Today's Date
Date2 = Yesterday's Date

I wrote a code that does that, but everytime it gets to the first of the month, I get "Date2" with current month and last day of previous month.

See my code below and thanks for the help.

Function Main()
if not (isdate(dtsglobalvariables("YesterdaysDate"))) then
dtsglobalvariables("YesterdaysDate")=formatdatetime(date()-1,2)
end if
dtsglobalvariables("TodaysDate") =formatdatetime(cdate(dtsglobalvariables("YesterdaysDate"))+1,2)
Main = DTSTaskExecResult_Success
End Function


---

Thanks!
Igor.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-03-16 : 07:53:07
Not too sure if you can as usually do this in T-SQL instead, but use DateAdd("d",-1,date()) rather than date()-1..
Go to Top of Page
   

- Advertisement -