Question
How to convert date format from DD.MM.YYY to MM.DD.YYYY in Vantage?
Answer
- Create a separate text field, i.e. Date Test:
- In the Date Test field settings, add a new Advanced Script Rule:
- In the rule settings, enable fields that will be used in the script. Since the Date Test field will be modified, the option Changed by the rule should be enabled for this field:
- The sample script is below:
var invDateField = Context.GetField("Invoice Date");
if (invDateField != null && invDateField.IsValid)
{
var invDate = invDateField.Value;
let yyyy = invDate.getFullYear();
let mm = invDate.getMonth() + 1; // Months start at 0!
let dd = invDate.getDate();
let day = dd.toString();
let month = mm.toString();
if (dd < 10) day = '0' + dd;
if (mm < 10) month = '0' + mm;
var formatted = month + '.' + day + '.' + yyyy;
Context.GetField("Date Test").Value = formatted;
} - The result is the following:
Note: this is just a sample solution that needs to be altered based on the particular requirements.
Comments
0 comments
Please sign in to leave a comment.