- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Changing Date Format from Nominal to Numerical Data
Hi, I would like to change the below date field, which is a nominal field, to m/d/y format in jsl. Please help.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
Create a new numeric column
In the Col Info dialog window, set the format to m/d/y
Set a formula for the column of
Informat( :Day of Process Date, "Format Pattern", "<Month> <D>, <YYYY>" )
Here is a script that when run creates the above example data table
New Table( "Format Pattern",
Add Rows( 1 ),
New Column( "Day of Process Date",
Character,
"Nominal",
Set Values( {"November 8, 2024"} )
),
New Column( "New date",
Numeric,
"Nominal",
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Formula(
Informat(
:Day of Process Date,
"Format Pattern",
"<Month> <D>, <YYYY>"
)
)
)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
Format Pattern was released in JMP 16 so that is why the formula does not work. Here is a formula that works in JMP 15
If( Row() == 1,
monthList = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
}
);
Date MDY(
Contains( monthList, Word( 1, :Day of Process Date, ", " ) ),
Num( Word( 2, :Day of Process Date, ", " ) ),
Num( Word( 3, :Day of Process Date, ", " ) )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
Create a new numeric column
In the Col Info dialog window, set the format to m/d/y
Set a formula for the column of
Informat( :Day of Process Date, "Format Pattern", "<Month> <D>, <YYYY>" )
Here is a script that when run creates the above example data table
New Table( "Format Pattern",
Add Rows( 1 ),
New Column( "Day of Process Date",
Character,
"Nominal",
Set Values( {"November 8, 2024"} )
),
New Column( "New date",
Numeric,
"Nominal",
Format( "m/d/y", 12 ),
Input Format( "m/d/y" ),
Formula(
Informat(
:Day of Process Date,
"Format Pattern",
"<Month> <D>, <YYYY>"
)
)
)
)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
When I tried to run the sample script above, the New date column doesn't populate for me. I also tried doing adding the formula manually, and it still doesn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
What version of JMP are you using and on what operating system.
I ran the code on both JMPPro 18 and JMPPro 16 on a Windows 11 and it ran without an issue.
Do you have any messages in the log?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
No error message. I have JMP 15 and windows 10.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
Format Pattern was released in JMP 16 so that is why the formula does not work. Here is a formula that works in JMP 15
If( Row() == 1,
monthList = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
}
);
Date MDY(
Contains( monthList, Word( 1, :Day of Process Date, ", " ) ),
Num( Word( 2, :Day of Process Date, ", " ) ),
Num( Word( 3, :Day of Process Date, ", " ) )
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Changing Date Format from Nominal to Numerical Data
Thank you!