Expression in SSIS - Derived column to change the Date from the last SIX days

  • I am working on SSIS and my question is I am having an XML file data in that data one column header is I am working on SSIS and my question is I am having an XML file data in that data one column header is TIMESTAMP and the TIMESTAMP sample data is here:

    2013-08-02 00:15:00  2013-08-03 00:30:00  2013-08-04 00:45:00  2013-08-05 08:45:00  2013-08-06 08:45:01  2013-08-08 08:45:02


    In the above data, I have to change the Date to:

    2017-06-02 00:15:00  2017-06-03 00:30:00  2017-06-04 00:45:00  2017-06-05 08:45:00  2017-06-06 08:45:01  2017-06-08 08:45:02

    So, How can I write an Expression in the Derived Column to change the Date from last six days? Without Changing the 'TimeReading' that is side to the Date.

    That means the Date should change and pop up from previous 6 days and TimeReading next to the Date should be same as previous data.

    What I did:

    In the Expression,  I write expression GETDATE() output is populating with today's date and the TimeReading is populating with 00:00:00.

     I write expression GETDATE()-1, output is populating with the previous date and TimeReading is populating with 00:00:00,

    But I need to get the continuous date from the last six days with the same TimeReading.

    Can anyone help?

  • Try this,let me know if the below is what you are looking for(you can go back any number of days with date part)
     

    (DT_WSTR,4)YEAR(dateadd("day",-6,getdate()) + "-"   
    + RIGHT("0" + (DT_WSTR,2)MONTH(dateadd("day",-6,getdate()), 2) + "-"  
    + RIGHT("0" + (DT_WSTR,2)DAY(dateadd("day",-6,getdate()), 2) + " " 
    + RIGHT("0" + (DT_WSTR,2)DATEPART("hh", 'yourdate'), 2) + ":" 
    + RIGHT("0" + (DT_WSTR,2)DATEPART("mi", 'yourdate'), 2) + ":" 
    + RIGHT("0" + (DT_WSTR,2)DATEPART("ss",'yourdate'), 2)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply