Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Newbie2Jumpie
Level IV

Format( "d/m/y h") instead of format( "d/m/y h:m") possible. Scripting.

Hi,

Quick questions: I would like to build a format( "d/m/y h").

Is this possible like format( "d/m/y h:m")?

Kind regards, newbie

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Newbie2Jumpie
Level IV

Re: Format( "d/m/y h") instead of format( "d/m/y h:m") possible. Scripting.

I solved this issue by generating a numeric compound of values instead of using a format: 

My_DS << New Column( "My_Datetime", Numeric, "Continuous", Formula ( (Year(:MY_Value)*1000000) + (month(:MY_Value)*10000) + (day(:MY_Value)*100) + (hour(:MY_Value)) ) ) ;

View solution in original post

4 REPLIES 4
Highlighted
txnelson
Super User

Re: Format( "d/m/y h") instead of format( "d/m/y h:m") possible. Scripting.

You can easily set a Custom Format in the Column Info dialog box, and set the format to use

Format( :value, "d/m/y " ) || " " || Char( Hour( :value ) )

as the formula to create the format you want

Jim
Highlighted
Newbie2Jumpie
Level IV

Re: Format( "d/m/y h") instead of format( "d/m/y h:m") possible. Scripting.

You mean like this?

My_DS << new column( "My_Datetime_H", Numeric, "Continuous", Format( :value, "d/m/y " ) || " " || Char( Hour( :value ) ), Formula(:value ) ) ;

This still generates unformatted values. Even if I'd add a leading CHAR() to the "d/m/y" part...

Highlighted
Newbie2Jumpie
Level IV

Re: Format( "d/m/y h") instead of format( "d/m/y h:m") possible. Scripting.

I solved this issue by generating a numeric compound of values instead of using a format: 

My_DS << New Column( "My_Datetime", Numeric, "Continuous", Formula ( (Year(:MY_Value)*1000000) + (month(:MY_Value)*10000) + (day(:MY_Value)*100) + (hour(:MY_Value)) ) ) ;

View solution in original post

Highlighted
Craige_Hales
Staff (Retired)

Re: Format( "d/m/y h") instead of format( "d/m/y h:m") possible. Scripting.

You might want to revisit this. Jim's suggestion was (needs more than 12 for the width, using 20 here)

New Table( "Untitled 12",
	Add Rows( 1 ),
	New Column( "Column 1",
		Numeric,
		"Continuous",
		Format(
			"Custom",
			Formula( Format( value, "d/m/y " ) || " " || Char( Hour( value ) ) ),
			20
		),
		Set Selected,
		Set Values( [3653896068] ),
		Set Display Width( 206 )
	)
)

which you can get to interactively like this

Pick custom for the formatPick custom for the format

paste the JSL into the formula editor; this is the formula to format the value for displaypaste the JSL into the formula editor; this is the formula to format the value for display

desired output from a JSL date time valuedesired output from a JSL date time value

The reason you might want to revisit: as a numeric value you might be tempted to do arithmetic or statistics...which is not going to work well since it doesn't increase in a uniform way.

Craige
Article Labels

    There are no labels assigned to this post.