expression yyyymm with mm-1

  • In My derived column I want expression for getting yyyymm ( where mm is mm-1)

    Expression in Derived Column

    (DT_STR,4,1252)DATEPART("yyyy",GETDATE()) + RIGHT("0" + (DT_STR,2,1252)DATEPART("mm",GETDATE()),2)

    Result : 201407

    Expected Result : 201406

  • Shanmuga Raj (7/28/2014)


    In My derived column I want expression for getting yyyymm ( where mm is mm-1)

    Expression in Derived Column

    (DT_STR,4,1252)DATEPART("yyyy",GETDATE()) + RIGHT("0" + (DT_STR,2,1252)DATEPART("mm",GETDATE()),2)

    Result : 201407

    Expected Result : 201406

    Try this:

    (DT_STR,4,1252)DATEPART("yyyy",DATEADD("Month",-1,GETDATE())) + RIGHT("0" + (DT_STR,2,1252)DATEPART("mm",DATEADD("Month",-1,GETDATE())),2)

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

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