Nested IFs in Derived column transformation

  • I'm not sure how to go about this.  I have a series of dates that are strings in the input (month/day/year):

    4/23/2012
    1/21/2013
    3/4/2013
    04/02/2015

    I am using a derived column to transform them into output database timestamp [DT_DBTIMESTAMP].  I need to build a nested IF statement that converts the month to two characters if it is a single character and the day to two characters if it is a single character. Then I am converting the entire date to a database timestamp [DT_DBTIMESTAMP] if the length is 0.

    Any help is appreciated!

  • karen.ferrara - Monday, December 11, 2017 6:03 AM

    I'm not sure how to go about this.  I have a series of dates that are strings in the input (month/day/year):

    4/23/2012
    1/21/2013
    3/4/2013
    04/02/2015

    I am using a derived column to transform them into output database timestamp [DT_DBTIMESTAMP].  I need to build a nested IF statement that converts the month to two characters if it is a single character and the day to two characters if it is a single character. Then I am converting the entire date to a database timestamp [DT_DBTIMESTAMP] if the length is 0.

    Any help is appreciated!

    You don't need an IF for this. Instead, use:

    RIGHT( "0" +[MonthExpression],2)

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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