Domanda

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

È stato utile?

Soluzione

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))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top