cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
UberBock
Level III

Calendar Box question

When using the calendar box to allow users to select dates is there a way to set the time to a default time?  The reason is I am using it let the user select a date range which is used in a SQL to query data.  So if the user selects 1/1/2020 as the start and 3/1/2020 as the end they may miss data because they didnt set the time to 12:00:00 AM and 11:59:59 PM.  Can the calendar box could be set to default to those times

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Calendar Box question

If you initialize the calendar with a date+time but only show the date editor, the time will be remain the same when dates are selected.  Here's an example that ensures that you have the full days included at the endpoints:

 

Names Default To Here( 1 );
result = New Window( "Calendar Box Example",
	<<Modal,
	<<OnValidate(
		fromDate = fromCal << Get Date();
		toDate = toCal << Get Date();
		1;
	),
	H List Box(
		V List Box(
			Text Box( "From:" ),
			fromCal = Calendar Box( <<Date( Parse Date( "4/2/2002 12:00:00AM", "m/d/y h:m:s" ) ), <<Show Time( 0 ) )
		),
		V List Box(
			Text Box( "To:" ),
			toCal = Calendar Box( <<Date( Parse Date( "10/14/2003 11:59:59PM", "m/d/y h:m:s" ) ), <<Show Time( 0 ) )
		),

	)
);
If( result["Button"] == 1,
	New Window( "results",
		V List Box(
			Text Box( "From: " || Format( fromDate, "M/D/Y h:m:s" ) ),
			Text Box( "To: " || Format( toDate, "M/D/Y h:m:s" ) )
		)
	)
);

View solution in original post

3 REPLIES 3

Re: Calendar Box question

If you initialize the calendar with a date+time but only show the date editor, the time will be remain the same when dates are selected.  Here's an example that ensures that you have the full days included at the endpoints:

 

Names Default To Here( 1 );
result = New Window( "Calendar Box Example",
	<<Modal,
	<<OnValidate(
		fromDate = fromCal << Get Date();
		toDate = toCal << Get Date();
		1;
	),
	H List Box(
		V List Box(
			Text Box( "From:" ),
			fromCal = Calendar Box( <<Date( Parse Date( "4/2/2002 12:00:00AM", "m/d/y h:m:s" ) ), <<Show Time( 0 ) )
		),
		V List Box(
			Text Box( "To:" ),
			toCal = Calendar Box( <<Date( Parse Date( "10/14/2003 11:59:59PM", "m/d/y h:m:s" ) ), <<Show Time( 0 ) )
		),

	)
);
If( result["Button"] == 1,
	New Window( "results",
		V List Box(
			Text Box( "From: " || Format( fromDate, "M/D/Y h:m:s" ) ),
			Text Box( "To: " || Format( toDate, "M/D/Y h:m:s" ) )
		)
	)
);
Craige_Hales
Super User

Re: Calendar Box question

UberBock
Level III

Re: Calendar Box question

Thank you!   I can certainly use this