Skip to main content
This topic has been closed for replies.
Correct answer PDF Automation Station

I am not using a "Date" field. Day1.0 is the field I would like to select the date in (from a drop down calendar). End result would be "Day1.0" = DD, "Month1" = MM, "Year1" = YYYY


You can't use the same field twice (Day1.0) for two different values.  Change "Date" to "Day1.0" but then you'll have to change the name of the second instance of "Day1.0" to something else.

2 replies

try67
Community Expert
Community Expert
July 31, 2024

You can use the split command to split a string into an array of strings, based on a delimiter.

For example:

 

var d = "31-07-2024";

var a = d.split("-");

console.println(a[2]); // prints out "2024"

 

Participant
July 31, 2024

I do not know enough about scrpts to know how to use the split command.

PDF Automation Station
Community Expert
Community Expert
July 31, 2024

If your date format is "mm/dd/yyyy", and assuming the date field name is "Date", enter the following calculation scripts:

in DAY1 field

if(this.getField("Date").value)
{event.value=this.getField("Date").value.split("/")[1];}
else
{event.value=""}

in MONTH1 field

if(this.getField("Date").value)
{event.value=this.getField("Date").value.split("/")[0];}
else
{event.value=""}

in YEAR1 field

if(this.getField("Date").value)
{event.value=this.getField("Date").value.split("/")[2];}
else
{event.value=""}

If the format is "dd-mm-yyyy", change the separator to "-" example:  split("-") and change the numbers in the square brackets.  [0] is the first item in the split, [1] is the second item, and [2] is the third item.

 

PDF Automation Station
Community Expert
Community Expert
July 31, 2024

What is the date format of DAY1?