Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I format date value as yyyy-mm-dd using SSIS expression builder?

Tags:

ssis

hi I have taking flatfile source name dynamically I.e. filename like "source 2011-08-11" I'm creating expression builder for taking most recent file as per filename. I did like Created one variable which is having folder path : C\backup\

now inside expression builder how can i add date ??? i tried like

@[User::DirPath]+"source"+ (DT_STR,4,1252)YEAR( DATEADD( "dd", -1, getdate() )) +"-"+(DT_STR,4,1252)MONTH( DATEADD( "dd",-1, getdate() ))+"-"+(DT_STR,4,1252)  DAY(DATEADD( "dd", -1, getdate() )) +".CSV" 

which is wrong please give me the expression which gives me output : "source 2011-08-11"

like image 321
Neo Avatar asked Aug 03 '11 06:08

Neo


People also ask

How do I convert datetime to date in SSIS?

To convert Datetime to Date, we have to use "DT_DBDATE" data type.

How do you write expressions in SSIS?

For example, the expression Column1 + " ABC" can be used to update a value or to create a new value with the concatenated string. Variables use an expression to set their value. For example, GETDATE() sets the value of the variable to the current date.


1 Answers

Correct expression is

"source " + (DT_STR,4,1252)DATEPART( "yyyy" , getdate() ) + "-" + RIGHT("0" + (DT_STR,4,1252)DATEPART( "mm" , getdate() ), 2) + "-" + RIGHT("0" + (DT_STR,4,1252)DATEPART( "dd" , getdate() ), 2) +".CSV" 
like image 59
Deepankar Sarkar Avatar answered Oct 07 '22 17:10

Deepankar Sarkar