?
Solved

SSIS expression syntax (w/ variables)

Posted on 2010-11-08
8
Medium Priority
?
330 Views
Last Modified: 2012-05-10
I have a variable
@{User::Path)
I need to append yesterday's date to this variable in this format (yyyymmdd) to the path. For example,
20101107 (If a month or day is single digit, it needs to precede with a zero '0')
0
Comment
Question by:spirose
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Expert Comment

by:Humpdy
ID: 34086171
this was solved earlier.

you can see this link for step by step resolution.
http://www.sqlnerd.com/ssis_dynamic_dates.htm
0
 

Author Comment

by:spirose
ID: 34086213
How do I modify this expression to get yesterday's date instead of today's? Thanks in advance!
0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 34086592
This way

SELECT  CONVERT(VARCHAR(10),DateAdd(day,-1,GETDATE()),112)
      
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:spirose
ID: 34086610
Sorry but this has to be in SSIS expression syntax....
The above only works in SQL Server...
0
 
LVL 16

Accepted Solution

by:
vdr1620 earned 500 total points
ID: 34086677
You can use the below exp
@[User::Path]+(DT_STR,4,1252)YEAR(Dateadd("D",-1,getdate()))+
Right("0" + (DT_STR,4,1252) Month(Dateadd("d",-1,getdate())),2) +
Right("0" + (DT_STR,4,1252) Day(Dateadd("d",-1,getdate())),2)

Open in new window

0
 
LVL 16

Expert Comment

by:vdr1620
ID: 34086697
Actually you can decrease the size..use this modified Exp
@[User::Path]+(DT_STR,4,1252)Year(Dateadd("D",-1,getdate()))+
Right("0" + (DT_STR,2,1252) Month(Dateadd("d",-1,getdate())),2) +
Right("0" + (DT_STR,2,1252) Day(Dateadd("d",-1,getdate())),2)

Open in new window

0
 
LVL 19

Expert Comment

by:Bhavesh Shah
ID: 34086715

I should say sorry.
anyways try this.

Select REPLACE(CAST(DT_DBDATE,DATEADD("day", -1, getdate())),"-","")

there could be some syntax error as I dont have anything to test it
0
 

Author Closing Comment

by:spirose
ID: 34086754
Thank you!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question