Subscribe Bookmark RSS Feed

Re: digits to appear as double digits

DKI

Occasional Contributor

Joined:

Feb 13, 2017

Hi

 

The JSL script below is outputting a week number from a data in JSL. however it outputs the lower weeks as 1-9 in single digits however, I need these to appear in double digits ie 01 instead of 1, 02 instead of 2..etc.

 

I am hoping someone knows a way to do this, any ideas would be great.

 

JSL script

ST << New Column( "ww",

Numeric,

"Nominal",

Format( "Best", 12 ),

Formula( Week Of Year( :time ) )

);

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

If you are using JMP 13, in your script, set the format to:

Format(
	"Custom",
	Formula( Substr( "00", 1, 2 - Length( Char( value ) ) ) || Char( value ) ),
	12
)

 

Jim
3 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Solution

If you are using JMP 13, in your script, set the format to:

Format(
	"Custom",
	Formula( Substr( "00", 1, 2 - Length( Char( value ) ) ) || Char( value ) ),
	12
)

 

Jim
Highlighted
DKI

Occasional Contributor

Joined:

Feb 13, 2017

Thanks alot Jim.

Spent ages trying to find something that could do that in the column info.

Not exactly sure how substring command is doing that but it works.

txnelson

Super User

Joined:

Jun 22, 2012

To learn about the Substr function and as a matter of fact, any of the functions, go to the Scripting Index.  For info on the Substring(Substr) function:

 

     Help==>Scripting Index==>Functions==>Character==>Substr

Jim