Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get current date in file name?

I am generating report everyday through SSRS. I am trying to get current date as file name when ever the job runs and file created.

Like this ID_report_03-31-2014

I have tried echo %date% %time% and @ExecutionTime but it doesn't work

like image 228
user3337941 Avatar asked Apr 02 '14 21:04

user3337941


People also ask

How do I put the date in a FileName?

I'd use YYYY-MM-DD HHmmss for filenames, unless there is a particular need for timezones or a possible need to parse them into ISO dates; in those cases an ISO date would probably be preferrable.

How do you create a file with today's date?

You should use double quotes and need to evaluate date +"%F" using command substitution. Double quote helps you create a single file where some options of date command would include a space. For example, touch test_$(date) will create multiple files, where as touch "test_$(date)" won't.

How do I get today's date in bash?

Sample shell script to display the current date and time #!/bin/bash now="$(date)" printf "Current date and time %s\n" "$now" now="$(date +'%d/%m/%Y')" printf "Current date in dd/mm/yyyy format %s\n" "$now" echo "Starting backup at $now, please wait..." # command to backup scripts goes here # ...


2 Answers

The main option with a file share subscription is to add @timestamp to the file name.

From File Share Delivery in Reporting Services:

An alternative approach to creating unique files for every delivery is to include a timestamp in the file name. To do this, add the @timestamp variable to the file name (for example, CompanySales@timestamp). With this approach, the file name is unique by definition, so it will never be overwritten.

I don't know if this is exactly what you are after, since it will include a time component, but as far as a standard SSRS subscription goes your options are limited.

Edit after comment

You don't have a lot of control over the format here.

On the MS forums one of there support suggests using Data Driven Subscriptions to get more control:

Can we edit @timestamp variable in SSRS:

In this case, we can define the filename with timestamp in database and then use Data-Driven Subscriptions to delivey the report.

But that seems a poor option to me, but is the only suggestion out there that I can see.

like image 154
Ian Preston Avatar answered Nov 02 '22 18:11

Ian Preston


I have solved that problem using Data Driven Subscription. I found the solution here.

like image 27
user3337941 Avatar answered Nov 02 '22 18:11

user3337941