- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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 );
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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" ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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" ) );
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
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.