SQL Server Performance

Using GETDATE() in a DTS Package

Discussion in 'SQL Server DTS-Related Questions' started by sueolo, Mar 22, 2005.

  1. sueolo New Member

    Hi, all. This is my first posting, so please bear with me!

    I created a DTS package to query two tables and generate a comma-delimited file. One part of the query compares today's date to a date in my table. The DTS (Export) Wizard only seems to allow me to select a specific date; i.e., the current day's date or another date. Selecting the current day's date creates a comma-delimited file with the correct data. I would like to use GETDATE() in place of today's date, but when I do this I get an empty comma delimited file. Is there any way around this? I don't want to have to edit (or create a new package) daily with the current day's date - we want to create a DTS package that will run automatically once a day.

    Any help you can provide will really be appreciated.

    Thank you,

  2. sueolo New Member

    I found what I needed. Here it is:

    DECLARE @myDate smalldatetime
    SET @myDate=CONVERT(varchar(25), GETDATE(), 106)

    @myDate now contains the current day's date. I added this to the SQL query in my DTS package, and it works fine.

    - Sue

Share This Page