문제

I have the following SQL statement:

DATEADD( DAY, 0 - (DATEPART(weekday, GETDATE()) % 7), GETDATE() )

Which returns:

2014-04-19 10:10:02.757

How can I change the SQL statement to use in SSIS package expression to get the last saturday's date in this format:

4-19-2014

When I tried the sql statement in expression builder, I get the following error:

enter image description here

도움이 되었습니까?

해결책

Try using the following for the expression:

(DT_WSTR,10)(RIGHT("0" + (DT_STR, 2, 1252) DATEPART("mm" , DATEADD("D", 0 - (DATEPART("weekday", GETDATE()) % 7) , GETDATE())), 1) + "-" + RIGHT("0" + (DT_STR, 2, 1252) DATEPART("dd" , DATEADD("D", 0 - (DATEPART("weekday", GETDATE()) % 7) , GETDATE())), 2) + "-" + RIGHT("0" + (DT_STR, 4, 1252) DATEPART("yy" , DATEADD("D", 0 - (DATEPART("weekday", GETDATE()) % 7) , GETDATE())), 4))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top