cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
terapin
Level VI

Calendar Box Question

When using the calendar box to allow users to select a single date, is there a way to set the time to 12:00:00AM of the date selected? I ask because with the code I'm using below, each time I select a given date (e.g., August 1, 2022) I get a slightly different value depending on the time of day when the code was run.

 

Ultimately, I'm using the calendar box to select a given date and to then select rows in a data table where sdate == Date and which is derived from a formula (Date MDY( :Month, :Day, :Year ).

nw = New Window( "Instrument Linearity Test Date",
	<<modal(),
	Text Box( "Select Date of Linearity Test" ),
	Panel Box( "Date", cal_start = Calendar Box( <<Show Time( 0 ) ), ),
	ok_button = Button Box( "OK", sdate = cal_start << get date )
);

Show( sdate );

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Calendar Box Question

You can just subtract off the seconds since midnight.

 

sdate = Today();

Show( Format( sdate, "m/d/y h:m" ) );

sdate -= Modulo( sdate, In Days( 1 ) );

Show( Format( sdate, "m/d/y h:m" ) );

View solution in original post

4 REPLIES 4
Craige_Hales
Super User

Re: Calendar Box Question

Take a look at Select Date Range with Calendar Boxes . See if the "roundMidnight" function and the OnClose for the modal dialog will do what you need.

@danschikore 

Craige

Re: Calendar Box Question

You can just subtract off the seconds since midnight.

 

sdate = Today();

Show( Format( sdate, "m/d/y h:m" ) );

sdate -= Modulo( sdate, In Days( 1 ) );

Show( Format( sdate, "m/d/y h:m" ) );
pmroz
Super User

Re: Calendar Box Question

Here's a way to take the time off of the date:

nw = New Window( "Instrument Linearity Test Date",
	<<modal(),
	Text Box( "Select Date of Linearity Test" ),
	Panel Box( "Date", cal_start = Calendar Box( <<Show Time( 0 ) ), ),
	ok_button = Button Box( "OK", sdate = cal_start << get date )
);

Show( sdate );

trunc_dt = informat(format(sdate, "ddMonyyyy"), "ddMonyyyy");

show(trunc_dt);
terapin
Level VI

Re: Calendar Box Question

Dang, I got a hat trick of outstanding suggestions from some heavy hitters.  Thanks fellas for weighing in on this and offering some helpful and informative suggestions.