Page 1 of 1

Convert Strings to Dates

Posted: Wed Sep 20, 2017 3:46 pm
by Grodaes
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

Re: Convert Strings to Dates

Posted: Tue Oct 03, 2017 10:29 am
by Support_Andy
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'