Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Date in Expression Builder Expand / Collapse
Author
Message
Posted Tuesday, March 4, 2008 7:15 AM


SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Monday, July 28, 2008 12:22 PM
Points: 87, Visits: 147
I'm trying to build an expression for the remote path in an FTP Task. When I enter

"/out/export/" + (DT_WSTR, 4) YEAR( GETDATE() ) + RIGHT( "0" + (DT_WSTR, 2) MONTH( GETDATE() ) , 2 ) everything work fine.

However, when I add + RIGHT("0" + (DT_WSTR,2) DatePart("dd", -1, GETDATE()),2) I get a truncation error. What I'm trying to do is make sure that I have a two digit day.

Any help would be appreciated.

Tim
Post #463759
Posted Tuesday, March 4, 2008 10:09 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 2:10 PM
Points: 2,278, Visits: 3,054
The easiest method would be to make a variable that evaulates as an expression. Your variable expression should look like this
"/out/export/" + RIGHT("0" + (DT_WSTR,2) datepart("d",Dateadd("dd", -1, GETDATE())),2)

Then in the connection string expression just call the variable.

RIGHT("0" + (DT_WSTR,2) DatePart("dd", -1, GETDATE()),2)

This will always produce errors because you are providing to many parameters for datepart. The datepart parameters are (datepart,date). I think you are tying to use dateadd which requires three parameters (interval,numer, date).

I resolved what I believe you were trying to accomplish in the code block above.




My blog: http://jahaines.blogspot.com
Post #463900
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse