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 2012 Forums
 SSIS and Import/Export (2012)
 SSIS expression for weekend

Author  Topic 

gaktheknife
Starting Member

12 Posts

Posted - 2015-04-29 : 10:14:37
I use the following expression to account for weekends when outputting to excel. How can i get this to be just the date like 20150429 instead of the full start time.

((DT_I4)DATEPART("weekday",@[System::StartTime]) ==2 ?

Replace((DT_STR, 20, 1252)(DATEADD( "D", -3,@[System::StartTime])),":","") +
".xlsx" :
Replace((DT_STR, 20, 1252)(DATEADD( "D", -1,@[System::StartTime])),":","") +
".xlsx")

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-04-29 : 11:11:13
[code]
LEFT(
REPLACE(
(DT_STR, 20, 1252)(DATEADD( "D",
(DT_I1)DATEPART("weekday",@[System::StartTime]) ==2 ? -3 : -1,
@[System::StartTime])),"-","")
,8) + ".xlsx"
[/code]
Go to Top of Page

gaktheknife
Starting Member

12 Posts

Posted - 2015-04-29 : 11:43:33
Awesome! Thank you
Go to Top of Page
   

- Advertisement -