Todd_Fields
asked on
SSIS Date Expressions: 2 digit day and month.
Hi,
I can't seem to figure out how to use the SSIS Expression syntax to ensure that the date is 8 digits for use in my file name (ex. 1333_Book2Book_20100129.tx t). The below only gets me 2010129.txt.
(DT_WSTR, 4) YEAR (GetDate() ) + (DT_WSTR, 2) Month (GetDate() ) + (DT_WSTR, 2) Day(GetDate() )
I have a function that I can call in SQL task to get a date in the right format, but I can't figure out how to save it to a variable. I get an error with types mismatches. I cast the value as varchar(8) and the variable is a string.
Any help would be much appreciated.
Thanks,
Todd
I can't seem to figure out how to use the SSIS Expression syntax to ensure that the date is 8 digits for use in my file name (ex. 1333_Book2Book_20100129.tx
(DT_WSTR, 4) YEAR (GetDate() ) + (DT_WSTR, 2) Month (GetDate() ) + (DT_WSTR, 2) Day(GetDate() )
I have a function that I can call in SQL task to get a date in the right format, but I can't figure out how to save it to a variable. I get an error with types mismatches. I cast the value as varchar(8) and the variable is a string.
Any help would be much appreciated.
Thanks,
Todd
check here for all other useful formattings...
http://www.sqlusa.com/bestpractices/datetimeconversion/
http://www.sqlusa.com/bestpractices/datetimeconversion/
ASKER
That still produces the error in the SQL Task that it is not in the format of my variable. I've attached a screen shot of the variable and error.
SQL-to-Variable.jpg
SQL-Task.jpg
SQL-to-Variable.jpg
SQL-Task.jpg
use
CONVERT(VARCHAR(10), GETDATE(), 112)
CONVERT(VARCHAR(10), GETDATE(), 112)
ASKER
Hi Hain,
You had mentioned this convert SQL above. If I don't use the keyword SELECT, it won't parse. The screen shot, although cut off does have:
Select CONVERT(VARCHAR(10), GETDATE(), 112) as uRunDate
Let me know if I missed your response.
Thanks,
Todd
You had mentioned this convert SQL above. If I don't use the keyword SELECT, it won't parse. The screen shot, although cut off does have:
Select CONVERT(VARCHAR(10), GETDATE(), 112) as uRunDate
Let me know if I missed your response.
Thanks,
Todd
looks good, now I guess you need to bind the value to your parameter
check here
http://www.sqlservercentral.com/Forums/Topic615235-148-1.aspx
check here
http://www.sqlservercentral.com/Forums/Topic615235-148-1.aspx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll continue to work on this on Monday. Thanks again.
SELECT CONVERT(VARCHAR(10), GETDATE(), 112) AS [YYYYMMDD]