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 2005 Forums
 SSIS and Import/Export (2005)
 Date Stamping

Author  Topic 

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-01-23 : 11:00:09
Hi

Does anyone know if it is possible to use SSIS to datestamp a filename? ie. 'test.txt' becomes 'test20080123.txt'

Thanks

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-23 : 11:22:13
Yes. When saving to a file, use a variable as the filename.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2008-01-24 : 10:09:33
How would you go about doing this?
Thanks
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-24 : 10:11:02
Please post back which pages in Books Online you have read and not understand, and we might be better able to assist you.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2008-01-24 : 13:53:00
[code]
Public Class ScriptMain
Public Sub Main()
'Goal: test20080123.txt'
Dim preTxt As String = "test"
Dim yyyy As String = Date.Today.Year.ToString
Dim mm As String = Date.Today.Month.ToString.PadLeft(2, CChar("0"))
Dim dd As String = Date.Today.Day.ToString.PadLeft(2, CChar("0"))
Dim ext As String = ".txt"
Dim filename As String = preTxt & yyyy & mm & dd & ext
MsgBox(filename)
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
[/code]

Good luck!
Go to Top of Page

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2008-01-29 : 14:57:54
On liner (mm and dd not padded but good enough):
Dim dt As String = "test" + Regex.Replace(DateTime.Now.ToString, "[^0-9]", String.Empty) + ".txt"
Go to Top of Page
   

- Advertisement -