Shanmuga Raj
Ten Centuries
Points: 1178
More actions
July 28, 2014 at 6:56 am
#148665
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
Lynn Pettis
SSC Guru
Points: 442467
July 28, 2014 at 7:11 am
#1732823
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 : 201407Expected Result : 201406
Shanmuga Raj (7/28/2014)
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