cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-347732%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ECambiar%20formato%20de%20fecha%20en%20un%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-347732%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ETengo%20un%20script%20que%20requiere%20que%20el%20usuario%20ingrese%20un%20tiempo%20de%20creaci%C3%B3n%20de%20lotes.%20Actualmente%20se%20ve%20as%C3%AD%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENew%20Window(%20%22BATCH_CREATE_TIME%22%2C%0A%20%26lt%3B%3CMODAL%3E%3C%2FMODAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EQuiero%20actualizar%20esto%20para%20que%20autom%C3%A1ticamente%20coloque%20la%20hora%20actual%20en%20el%20cuadro%20de%20texto%2C%20hasta%20ahora%20tengo%20esto%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ECurrTime%20%3D%20As%20Date(Today())%3B%20%0A%0ANew%20Window(%20%22BATCH_CREATE_TIME%22%2C%0A%20%26lt%3B%3CMODAL%3E%3C%2FMODAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EAhora%20todo%20lo%20que%20quiero%20hacer%20es%20cambiar%20la%20salida%20para%20que%20coincida%20con%20el%20formato%20original.%20Actualmente%20obtengo%20el%20formato%20%2201%20de%20enero%20de%202021%3A%2009%3A%2000%3A%2000%22.%20Idealmente%2C%20me%20gustar%C3%ADa%20que%20fuera%20%2201%2F01%2F2021%2009%3A00%3A00.000000%22%20(los%20segundos%20decimales%20no%20son%20vitales).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECualquier%20forma%20en%20que%20pueda%20cambiar%20el%20formato%20del%3CEM%3E%20como%20fecha%3C%2FEM%3E%20%C2%BFfunci%C3%B3n%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGracias%20a%20todos.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-347732%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3Esecuencias%20de%20comandos%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-347756%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20Cambiar%20formato%20de%20fecha%20en%20un%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-347756%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3ESu%20campo%20de%20entrada%20es%20un%20cuadro%20de%20texto%2C%20por%20lo%20que%20debe%20convertir%20la%20fecha%20de%20un%20n%C3%BAmero%20num%C3%A9rico%20de%20segundos%20a%20una%20cadena%20usando%20una%20funci%C3%B3n%20de%20formato%20()%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ECurrTime%20%3D%20format(As%20Date(Today())%2C%22m%2Fd%2Fy%20h%3Am%3As%22%2C6)%20%3B%20%0A%0ANew%20Window(%20%22BATCH_CREATE_TIME%22%2C%0A%20%26lt%3B%3CMODAL%3E%3C%2FMODAL%3E%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
HarriBradbeer
Level II

Change date format in a script

I have a script that requires the user to input a batch creation time. It currently looks like this:

 

 

New Window( "BATCH_CREATE_TIME",
	<<modal(),
	Panel Box( "Enter BATCH_CREATE_TIME",
		Lineup Box( N Col( 1 ) ),
		number = Text Edit Box( "01/01/2021 09:00:00.000000" )
	),
	Panel Box( "Actions",
		H List Box(
			Button Box( "OK",
				keep_going = 1;
				BATCH_TIME = number << Get text;
			),
			Button Box( "Cancel", keep_going = 0 )
		), 

	), 
);

I want to update this so that it automatically puts the current time into the text box, so far I have this:

 

 

CurrTime = As Date(Today()); 

New Window( "BATCH_CREATE_TIME",
	<<modal(),
	Panel Box( "Enter BATCH_CREATE_TIME",
		Lineup Box( N Col( 1 ) ),
		number = Text Edit Box( CurrTime )
	),
	Panel Box( "Actions",
		H List Box(
			Button Box( "OK",
				keep_going = 1;
				BATCH_TIME = number << Get text;
			),
			Button Box( "Cancel", keep_going = 0 )
		), 

	), 
);

Now all I want to do is change the output to match the original format. I currently get the format "01Jan2021:09:00:00". Ideally, I'd like this to be "01/01/2021 09:00:00.000000" (the decimal seconds aren't vital).

 

Any ways that I can change the format of the As Date function?

 

Thanks all.

 

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Change date format in a script

Your input field is a text box, so you need to convert the date from a numeric number of seconds, to a string using a format() function

CurrTime = format(As Date(Today()),"m/d/y h:m:s",6) ; 

New Window( "BATCH_CREATE_TIME",
	<<modal(),
	Panel Box( "Enter BATCH_CREATE_TIME",
		Lineup Box( N Col( 1 ) ),
		number = Text Edit Box( CurrTime )
	),
	Panel Box( "Actions",
		H List Box(
			Button Box( "OK",
				keep_going = 1;
				BATCH_TIME = number << Get text;
			),
			Button Box( "Cancel", keep_going = 0 )
		), 

	), 
);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: Change date format in a script

Your input field is a text box, so you need to convert the date from a numeric number of seconds, to a string using a format() function

CurrTime = format(As Date(Today()),"m/d/y h:m:s",6) ; 

New Window( "BATCH_CREATE_TIME",
	<<modal(),
	Panel Box( "Enter BATCH_CREATE_TIME",
		Lineup Box( N Col( 1 ) ),
		number = Text Edit Box( CurrTime )
	),
	Panel Box( "Actions",
		H List Box(
			Button Box( "OK",
				keep_going = 1;
				BATCH_TIME = number << Get text;
			),
			Button Box( "Cancel", keep_going = 0 )
		), 

	), 
);
Jim

Recommended Articles