A changing date for file name
I'm trying to export an Excel file using variables that are built into an expression. This part is simple and makes sense. The trouble I'm having is that this report will be run once a month and I want the Excel file to have both the month and year added to the file name. The expression is currently: @[User::Path]+@[User::Name] This works exactly the way I want, except it lacks the current month and year. I tried adding a "get-date()" function with no success. Anyone have an idea of how to get it to grab the current date? (I also tried creating a date variable and inserting it between the above variables, but it failed to work).
June 15th, 2012 12:13pm

@[User::Path]+@[User::Name]+ (DT_WSTR,4)YEAR(GETDATE()) + "-" + RIGHT("0" + (DT_WSTR,2)MONTH(GETDATE()), 2) + ".xls" Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2012 12:15pm

This should work @[User::Path]+ (DT_WSTR, 4 )YEAR(GETDATE() )+ (DT_WSTR, 2 )MONTH(GETDATE() ) + @[User::Name] Chuck Pedretti | Magenic North Region | magenic.com
June 15th, 2012 12:15pm

This should work @[User::Path]+ (DT_WSTR, 4 )YEAR(GETDATE() )+ (DT_WSTR, 2 )MONTH(GETDATE() ) + @[User::Name] Chuck Pedretti | Magenic North Region | magenic.com
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2012 12:19pm

@[User::Path]+@[User::Name]+ (DT_WSTR,4)YEAR(GETDATE()) + "-" + RIGHT("0" + (DT_WSTR,2)MONTH(GETDATE()), 2) + ".xls" Arthur My Blog
June 15th, 2012 12:19pm

Thanks; worked perfectly.
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2012 12:28pm

One quick question to check - this won't replace the file each month, but will add a new file with this date. So, for instance, it will be 62012File, 72012File and so on without replacing the file, correct?
June 21st, 2012 5:24pm

Yes it should create new files as long as the file names are not the same.
Free Windows Admin Tool Kit Click here and download it now
June 21st, 2012 7:41pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics