How to append formatted date to file name?
Comments
-
Is there a built-in way to add a formatted date to a filename? I want the date in format YYYY-MM-DD, and I want to maintain zeros as part of the date. For example, today is 27 August 2020, so that would be 2020-08-27. For example, 1 September 2020 would be 2020-09-01.
I’m able to use a “Replace Text in String” step to add the date, but the leading zeros in the month and day elements are lost. I am using Merge Plain Text for the “new Text to Insert” element of that step, and I’m using the following fields to get the current date:
[ul][li]Flow Data.StartTime.Year.Unformatted[/li][li]Flow Data.StartTime.Month.Unformatted[/li][li]Flow Data.StartTime.Day.Unformatted[/li][/ul]
I tried using Data.StartTime.Month.Default, but I still lose the leading zero. -
[font=Roboto, Arial, Helvetica, sans-serif]Ive created an example of how you might update the filename of documents with the current date at a constant length. Feel free to import, review, and modify it at your convenience. The key factor is that current_date.month and current_date.day will always be single-digit if the month or day is 9 or below. This example checks these values and adds a preceding zero XOR the date/month is < 9.[/font]