2/03/2011

Dynamic Date Generated File Name

When creating an SSRS Data Driven Subscription, the customer requested a need for adding the date (not time) to the exported file name.

The way this is done is to append the Year + Month + Day in SQL

Select

'Report_Name_' +
(
CONVERT(CHAR(4), YEAR( GETDATE() ) ) + '-' +
RIGHT('00' + CONVERT(VARCHAR(2), MONTH( GETDATE() ) ), 2) + '-' +
RIGHT('00' + CONVERT(VARCHAR(2), DAY( GETDATE() ) ), 2)
)
as 'File name'

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.