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
 Analysis Server and Reporting Services (2005)
 append date to exporting file name in SQL reportin

Author  Topic 

sukumaster
Starting Member

2 Posts

Posted - 2007-11-22 : 02:07:28
When exporting a report to another format, say excel,PDF; the file name is always set to the report name. Our client has a requirement where whenever a user exports a report to pdf, the timestamp of when the data of the report was made should be appended in the filename. Is there a way to do this in Reporting Services ?

example : Report name : Testreport

Exported file should be : Testingreport-November-22-2007.pdf

please help me in this

Thanks
suku

tm
Posting Yak Master

160 Posts

Posted - 2007-11-22 : 16:35:34
In your file connection set your Expression for ConnectionString to something like (replace your actual path and extension) ..

"F:\\Projects\\Test\\SimpleImportCSV\\SimpleImportCSV\\ImportTestCSV" + SUBSTRING((DT_STR, 30, 1252)(GETDATE()), 1, 10) + ".txt"

This will return path and filename with date.
Will give you ..
F:\Projects\Test\SimpleImportCSV\SimpleImportCSV\ImportTestCSV2007-11-22.txt


For filename with date and time use ..

"F:\\Projects\\Test\\SimpleImportCSV\\SimpleImportCSV\\ImportTestCSV" + REPLACE(SUBSTRING((DT_STR, 30, 1252)(GETDATE()), 1, 17),":", "") + ".txt"

Will give you ..
F:\Projects\Test\SimpleImportCSV\SimpleImportCSV\ImportTestCSV2007-11-22 1634.txt
Go to Top of Page
   

- Advertisement -