Skip to content

How to Generate the Current Date

Looking for an example project to get you started?
  • Support_Rick Offline
  • Support Specialist
  • Posts: 590
  • Joined: Tue Jul 17, 2012 2:12 pm
  • Location: Phoenix, AZ
  • Contact:

How to Generate the Current Date

Post by Support_Rick »

The CurrentDate function is one of the most common and useful functions in GoAnywhere Director, and the subject of Rick’s Tip of the Month.

Date and time stamps are used frequently throughout the Managed File Transfer (MFT) environment. Archiving files and folders, date specific file movement and date/time sensitive file processing are just a few of the business applications where the use of the CurrentDate function is essential.

GoAnywhere Director allows you to create date/time values through the use of this CurrentDate function. Let’s step through a common project scenario where we will copy a file from one folder to another, and append the current date to the file name.

To begin, create a project, add a copy task and then add a source file and destination similar to the example in Figure 1 below
Figure 1.png
Figure 1.png (16.6 KiB) Viewed 40521 times
On the advanced tab, place your cursor in the "File Name Suffix" field and then click the $VAR button on the right (Figure 2) to show the expression wizard (Figure3)
Figure 2.png
Figure 2.png (14.07 KiB) Viewed 40521 times
Figure 3.png
Figure 3.png (25.68 KiB) Viewed 40521 times
From the Expression Wizard, you can pick the functions you need to manipulate your variable data. In this example, we need to get the Current Date. Hover over “CurrentDate” in the Function column and the function description appears in the Description pane. By clicking on the “CurrentDate” function, the Field Value is updated to include the function. You then have the option to modify the pattern to match the desired format of the date needed, or accept the default.

For our example, we are using the default ISO standard date. Edit the field value to remove the pattern text and then press "Done" to update your file name suffix value.
Figure 4.png
Figure 4.png (13.87 KiB) Viewed 40521 times
Now, execute your project and review your job log. You will see that the copy task completed as follows:

Code: Select all

Executing task 'copy 1.0 (Copy file to Archive)' File 'C:\temp\gademo.txt' (228 bytes) was successfully copied to 'C:\temp\DestDirA\NewFileName.txt.2013-12-11' (228 bytes)
1 file(s) copied successfully
Finished task 'copy 1.0 (Copy file to Archive)'
Notice that the current date has been appended to the end of your destination file name.

Please feel free to contact Linoma Software with any questions or to inquire about our on-site Professional Services or Training Programs.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
  • davegagnon Offline
  • Posts: 2
  • Joined: Thu Feb 20, 2014 11:26 am

Re: How to Generate the Current Date

Post by davegagnon »

How do I embed the ${CurrentDate} in a filename ? I want to copy a file, change the filename to include the date.

Source filename myfile.txt
Destination filename myfile_feb_20_2014.txt


I tried embedding ${CurrentDate()} in the filename for the Destination but it arrives as myfile${CurrentDate()}.txt .


Dave
  • Support_Rick Offline
  • Support Specialist
  • Posts: 590
  • Joined: Tue Jul 17, 2012 2:12 pm
  • Location: Phoenix, AZ
  • Contact:

Re: How to Generate the Current Date

Post by Support_Rick »

Dave,

Try something like this:

Code: Select all

<copy label="Copy My File" sourceFile="C:\Temp\Test.txt" destFile="C:\Temp\MyFile_${CurrentDate(&apos;MMM_DD_yyyy&apos;)}.txt" version="1.0" />
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
  • davegagnon Offline
  • Posts: 2
  • Joined: Thu Feb 20, 2014 11:26 am

Re: How to Generate the Current Date

Post by davegagnon »

We're on Version 4.5.1 . I'm a new user and have only seen the GUI interface, you're code above is readable but I don't know how to apply in V 4.5.1 . Can you give me a GUI version ?

Dave
  • Support_Jon Offline
  • Support Specialist
  • Posts: 62
  • Joined: Thu Jul 19, 2012 9:15 am
  • Location: Ashland, NE
  • Contact:

Re: How to Generate the Current Date

Post by Support_Jon »

Dave,

Here is a screen shot of a project within Director using just the task element that Rick provided above.
copy_task_example.PNG
copy_task_example.PNG (20.66 KiB) Viewed 40185 times
I hope this helps.
Post Reply