Results 1 to 6 of 6

Thread: date timestamp

  1. #1
    Join Date
    Jan 2004
    Posts
    51

    Unanswered: date timestamp

    i am creating a DTS package that will query a table and move data to another table daily on same DB/SERVER. i want to be able to timestamp previous date into date column in destination table. There's no date on source but i need timestamp on each import and date for previous day b/c importing data are for previous day.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    You could use
    PHP Code:
    DECLARE @now DATETIME
    ,  @yesterday DATETIME

    SET 
    @now GetDate()
    SET @yesterday Convert(CHAR(8), DateAdd(day, -1GetDate()), 121
    You can also use the expressions by themselves if that works better.

    -PatP

  3. #3
    Join Date
    Jan 2004
    Posts
    51
    tables was already created and my package uses query to move data...
    how should i use that code? do i have to create a task in the package? or use it in my query?

  4. #4
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Just include those expressions (the stuff after the equal sign from my previoius post) in your query. Be sure to give them some column name, and it will be a lot easier if you give them the column names you want used in the destination table.

    -PatP

  5. #5
    Join Date
    Jan 2004
    Posts
    51
    thanks anyway
    i got it..
    i use under my select query
    (getdate() - 1) as stampdate
    it gives me virtual column with date timestamp and them i match it to my date column in the destination table

  6. #6
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Yep! At least I think that is what I said.

    -PatP

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •