Link to home
Start Free TrialLog in
Avatar of gvamsimba
gvamsimbaFlag for United Kingdom of Great Britain and Northern Ireland

asked on

SSIS Variable Expression to get dd-mm-yy format

Hi I have created a new variable in SSIS with string datatype and used the below expression which is giving me 03042019 but i want it as
03-04-19 which is in dd-mm-yy format. can someone please update the below expression to get my
desired result.

Many Thanks

RIGHT("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2) + RIGHT("0" + (DT_WSTR,2)DATEPART("mm",GetDate()) ,2) + (DT_WSTR,4)DATEPART("yyyy",GetDate())
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try:

RIGHT("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2) + "-" + RIGHT("0" + (DT_WSTR,2)DATEPART("mm",GetDate()) ,2) + "-" + (DT_WSTR,2)DATEPART("yyyy",GetDate()) 

Open in new window

Avatar of gvamsimba

ASKER

Hi Ryan I got the below error

A truncation occurred during evaluation of the expression.
the below works like a charm..

RIGHT("0" + (DT_WSTR,2)DATEPART("dd",GetDate()),2) + "-" + RIGHT("0" + (DT_WSTR,2)DATEPART("mm",GetDate()) ,2) + "-" + RIGHT("0" + (DT_STR,4,1252)DATEPART( "yyyy" , getdate() ), 2)
good
ASKER CERTIFIED SOLUTION
Avatar of gvamsimba
gvamsimba
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial