Convert Strings to Dates

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
2 posts Page 1 of 1

Grodaes

Posts: 10
Joined: Mon Dec 05, 2016 12:12 pm

Post by Grodaes » Wed Sep 20, 2017 3:46 pm
Hello,

Is there any way to convert strings to date objects? I am working with a string like 20170920 and I would like to convert that to a date for manipulation. Is there any way to achieve this in a GAMFT project?

Thanks!
Grodaes

Support_Andy

Posts: 7
Joined: Thu Feb 16, 2017 11:03 am

Post by Support_Andy » Tue Oct 03, 2017 10:29 am
To convert a string variable to a date object and modify that final date, the following steps can be used.
In this example the variable with a string of '20170920' is called ${varstring}
  • Using the Set Variable task and assigning a Variable Name of "varnew"
    value = ${ReformatDateTime(varstring, 'yyyyMMdd', 'MM-dd-YYYY')}
From there the ${varnew} variable can be adjusted
  • Using another Set Variable task and assigning a Variable Name of "adjusttime"
    value = ${AdjustDateTime(varnew, 'MM-dd-yyyy', 'days', -60)}
The + or - at the end can be used to modify the date by a specific number and the 'days' value in the variable can be modified to 'months' or 'years'
Finally the ${adjusttime} variable can be used in any subsequent tasks that need an adjusted time variable

In the sample shown the ${adjusttime} variable value = '07-23-2017'
2 posts Page 1 of 1