Quantcast
Channel: Welcome To TechBrothersIT
Viewing all articles
Browse latest Browse all 1874

MonthName and Day Name in SSIS

$
0
0
Scenario:
Some time we have requirement to send email with MonthName or dayName in the subject,
Create folder with Month Name and then Archive files e.g. Archive_Dec_2011.


Solution:
We don't have MonthName or DayName in SSIS
we can create two variables in our package and write expression on them to use them whereever we need MonthName and DayName.


Step1:
Lets create VarDayName and VarMonthName variables in our package as show in picture.





Step2:
Go to the properties of VarDayName variable and then configure as shown in picture


Expressions:


DATEPART("dw",GETDATE())==1? "Sunday":
DATEPART("dw",GETDATE())==2?"Monday":
DATEPART("dw",GETDATE())==3?"Tuesday":
DATEPART("dw",GETDATE())==4?"Wednesday":
DATEPART("dw",GETDATE())==5?"Thursday":
DATEPART("dw",GETDATE())==6?"Friday":
DATEPART("dw",GETDATE())==7?"Saturday":""


Step3:
Go to the properties of DayMonthName variable and configure as show in picture.



Expressions:
(MONTH(getdate()) == 1 ? "Jan" :
MONTH(getdate()) == 2 ? "Feb" :
MONTH(getdate()) == 3 ? "Mar" :
MONTH(getdate()) == 4 ? "Apr" :
MONTH(getdate()) == 5 ? "May" :
MONTH(getdate()) == 6 ? "Jun" :
MONTH(getdate()) == 7 ? "Jul" :
MONTH(getdate()) == 8 ? "Aug" :
MONTH(getdate()) == 9 ? "Sep" :
MONTH(getdate()) == 10 ? "Oct" :
MONTH(getdate()) == 11 ? "Nov" :
MONTH(getdate()) == 12? "Dec":"")



Now you have Month Name and DayName available through these two variables ,
Those can be used in expression with different transformations as required.

Viewing all articles
Browse latest Browse all 1874

Trending Articles