Monday 29 September 2014

Write Expression For a Variable



           In this post i am going to explain, how to write expressions for variables.

Example: I need a string variable. The variable value should be current date, date format is "YYYYMMDD".

  • Create a variable (Sample_Date) with string data type.
 

  •  Select the variable and press "F4", then variable properties will open.
 

  •  Set "EvaluateAsExpression" value as "True".
  • Go to Expressions and write the below mentioned expression for current date.
Expression: 
SUBSTRING((DT_WSTR, 10) (DT_DBDATE) GETDATE(), 1,4)
+SUBSTRING((DT_WSTR, 10) (DT_DBDATE) GETDATE(), 6,2)
+SUBSTRING((DT_WSTR, 10) (DT_DBDATE) GETDATE(), 9,2)


  • Save the SSIS package then we can see the variable value.



No comments:

Post a Comment