cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
itsalkskeith
Level I

Converting Date from String format (d/m/y) to Numeric value (ddMonyyyy)

I have a String column with date values in format "d/m/y",Date Capture.PNG

however when converting via jsl using the following script:

Column( dt, "Date" ) << data type( numeric );
Column( dt, "Date" ) << Set modeling type( "Continuous" );
Column( dt, "Date" ) << Format( "ddMonyyyy" );

Date change capture.PNG

it returns it in the correct "ddMonyyyy" format, but it has swapped month with day so instead of seeing 05May2018 it shows 05Sep2018.

 

From executing the script line by line I can see that when it converts the data type from string to numeric the value that gives a value of 3618950400, which corresponds to 05Sep2018, I believe this is due to jmp interpreting m/d/y as being the regional date and time settings (which I cannot change).

 

However if I go to change the Date columns format manually I can get the correct Date outputDate last capture.PNG

I can correct this by manipulating the string and swapping the day and month with one another but this is far from desireable.

 

Is there any other way of achieving this using JSL?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: Converting Date from String format (d/m/y) to Numeric value (ddMonyyyy)

The <<Data Type() message will take the Format() and Input Format() as well, so you can do it all in one step.

 

:Date << data type( "numeric", Format( "ddMonYYYY" ), Input format( "ddmmyyyy" ) );
-Jeff

View solution in original post

1 REPLY 1
Jeff_Perkinson
Community Manager Community Manager

Re: Converting Date from String format (d/m/y) to Numeric value (ddMonyyyy)

The <<Data Type() message will take the Format() and Input Format() as well, so you can do it all in one step.

 

:Date << data type( "numeric", Format( "ddMonYYYY" ), Input format( "ddmmyyyy" ) );
-Jeff