Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Quick SSIS Expression Builder Question

Author  Topic 

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2007-07-26 : 12:33:13
This works:
len ((DT_WSTR,2)DATEPART("mm", getdate()))==1 ? (DT_WSTR,1)0 + (DT_WSTR,1)DATEPART("mm", getdate()) : (DT_WSTR,4)DATEPART("mm", getdate())

This doesn't:
"dataware/"+ len ((DT_WSTR,2)DATEPART("mm", getdate()))==1 ? (DT_WSTR,1)0 + (DT_WSTR,1)DATEPART("mm", getdate()) : (DT_WSTR,4)DATEPART("mm", getdate())

I tried a couple of different things at this point, where am I missing the cast? Before len? Cast to what?

nr
SQLTeam MVY

12543 Posts

Posted - 2007-07-27 : 11:29:57
You are concatenating the length of the returned string with "dataware/" - is that what you want?
try castinmg the len to a string.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2007-07-30 : 12:34:28
Correct, that a RemotePath that I'm passing to my FTP download component. See below my workaround this issue.

"/dataware/" + (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) +
".zip"

Cool SSIS Expressions Reference when dealing with dates.

http://wiki.sqlis.com/default.aspx/SQLISWiki/ExpressionDateFunctions.html
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2007-07-31 : 09:08:21
There you are concatenating the date with "dataware/" not the length.


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

igorblackbelt
Constraint Violating Yak Guru

407 Posts

Posted - 2007-07-31 : 09:32:04
The length was checking if the day was 1 or 2 digits, if it was a 1 digit length it would add a 0 in front of it, didn't make sense, did it?
Go to Top of Page
   

- Advertisement -