SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 SSIS Connection String If Statement
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ZMike
Posting Yak Master

110 Posts

Posted - 03/04/2013 :  16:21:03  Show Profile  Reply with Quote
Good Afternoon Everyone,

I'm trying to figure out the IF Statement for connections strings.

Basically if

GETDATE() = Monday

I believe I'd use this

RIGHT("0" + (DT_STR,4,1252) DATEPART("DW", GETDATE() ),2) =02

THEN

"/data/TransferData"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M", GETDATE()),2)
+RIGHT("0" +

(DT_STR,4,1252) DATEPART("D",DATEADD("D", -3, GETDATE())) ,2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
"-"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M",GETDATE()),2)
+
RIGHT("0" + (DT_STR,4,1252) DATEPART("D",GETDATE()),2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
".csv"

ELSE

"/data/TransferData"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M", GETDATE()),2)
+RIGHT("0" +

(DT_STR,4,1252) DATEPART("D",DATEADD("D", -1, GETDATE())) ,2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
"-"

+
RIGHT("0" + (DT_STR,4,1252) DATEPART("M",GETDATE()),2)
+
RIGHT("0" + (DT_STR,4,1252) DATEPART("D",GETDATE()),2)
+
(DT_WSTR, 4) YEAR( GETDATE() )
+
".csv"


Can anyone tell me how to achieve this ?


visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 03/05/2013 :  00:02:48  Show Profile  Reply with Quote
can you explain your rules in words first on how you want filename to come?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ZMike
Posting Yak Master

110 Posts

Posted - 03/05/2013 :  08:45:59  Show Profile  Reply with Quote
Visakh16, My file names are actually correct how I have them. On Mondays I instead of "/data/TransferData03032013-03042013.csv I just need to change the getdate -1 to getdate -3 so it pulls Friday - Monday

So on Mondays Getdate -3 as the a starting date, and getdate is always today as a standard.

Tuesday - Friday GetDate()-1 to Getdate
I can totally ignore Saturday and Sunday since thouse are included in the Monday files.

Does that help ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 03/05/2013 :  08:47:57  Show Profile  Reply with Quote
yep...do you've a calendar table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000