Page 1 of 1

How to Generate the Current Date

Posted: Mon Dec 23, 2013 9:33 am
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 9667 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 9667 times
Figure 3.png
Figure 3.png (25.68 KiB) Viewed 9667 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 9667 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.

Re: How to Generate the Current Date

Posted: Thu Feb 20, 2014 11:38 am
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 .


Re: How to Generate the Current Date

Posted: Thu Feb 20, 2014 7:24 pm
by Support_Rick

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" />

Re: How to Generate the Current Date

Posted: Fri Feb 21, 2014 10:38 am
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 ?


Re: How to Generate the Current Date

Posted: Wed Mar 26, 2014 11:24 am
by Support_Jon

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