Unless there is a real reason to keep the Target Date values as a character column, I suggest you convert it to a JMP Date column.
Names Default To Here( 1 );
dt = Current Data Table();
dt << new column( "Target Date", format( "ddmonyyyy") );
for each row(
if( :"Time (Months)"n <= 3,
:Target Date =
Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
:Target Date =
Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 )
)
);
![d1.PNG d1.PNG](https://community.jmp.com/t5/image/serverpage/image-id/31351i563A44C242457D0D/image-size/large?v=v2&px=999)
It is very easy to convert the above output to character by the below modification
Names Default To Here( 1 );
dt = Current Data Table();
dt << new column( "Target Date", character );
for each row(
if( :"Time (Months)"n <= 3,
:Target Date = format(
Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
"ddmonyyyy"
),
:Target Date = format(
Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 ),
"ddmonyyyy"
)
)
);
![d2.PNG d2.PNG](https://community.jmp.com/t5/image/serverpage/image-id/31352i759FC8853926EE42/image-size/large?v=v2&px=999)
If the output format needs to be exactly as the input data format is, the following will get that accomplished
Names Default To Here( 1 );
dt = Current Data Table();
dt << new column( "Target Date", character );
monthList = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP",
"OCT", "NOV", "DEC"};
for each row(
if( :"Time (Months)"n <= 3,
temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 )
);
:Target Date = Substr( "0", Length( Char( Day( temp ) ) ) ) ||
Char( Day( temp ) ) || "-" || monthList[Month( temp )] || "-" ||
Char( Year( temp ) );
);
![d3.PNG d3.PNG](https://community.jmp.com/t5/image/serverpage/image-id/31353i7595871343EBB232/image-size/large?v=v2&px=999)
If you wanted to use a formula rather than the For Each Row, this would be for formula for the above output
monthList = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
If( :"Time (Months)"n <= 3,
temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 4 ),
temp = Informat( :Available Date, "ddmonyyyy" ) + In Days( 7 )
);
Substr( "0", Length( Char( Day( temp ) ) ) ) || Char( Day( temp ) ) || "-" || monthList[Month( temp )] || "-" ||
Char( Year( temp ) );
Jim