Solved it with the following code. Probably not “Best Practice” as I’m a newbie, but seems pretty robust. Comments appreciated.
Global Method:
// Get dialog TEXT and convert to start DATE with 00:00:00
var start = plugins.dialogs.showInputDialog(‘Date Range’,‘Enter START Date, i.e. 06-01-2006’);
if (start == null)// If empty, exit method
{
globals.gStartDate = null;
return;
}
if (start.length != 10)// Validate format to facillitate parsing
{
application.beep()//show dialog
var thePressedButton = plugins.dialogs.showErrorDialog(‘Formatting Error’, ‘Please use leading zeros and 4-digit years.’,‘OK’);
globals.gStartDate = null;
return;
}
var mymonth = utils.stringLeft(start, 2);
var myday = utils.stringMiddle(start, 4, 2);
var myyear = utils.stringRight(start, 4);
var startdate = new Date(myyear, mymonth-1, myday);//Convert text to date
//Set time to start of range
startdate.setHours(00);
startdate.setMinutes(00);
startdate.setSeconds(00);
globals.gStartDate = startdate;//This is the global used in form-specific methods
// Get dialog TEXT and convert to end DATE with 23:59:59
var end = plugins.dialogs.showInputDialog(‘Date Range’,‘Enter END Date, i.e. 07-05-2006’);
if (end == null)// If empty, exit method
{
globals.gEndDate = null;
return;
}
if (end.length != 10)// Validate format to facillitate parsing
{
application.beep()//show dialog
var thePressedButton = plugins.dialogs.showErrorDialog(‘Formatting Error’, ‘Please use leading zeros and 4-digit years.’,‘OK’);
globals.gEndDate = null;
return;
}
var mymonth = utils.stringLeft(end, 2);
var myday = utils.stringMiddle(end, 4, 2);
var myyear = utils.stringRight(end, 4);
//Convert text to date
var enddate = new Date(myyear, mymonth-1, myday);
//Set time to end of range
enddate.setHours(23);
enddate.setMinutes(59);
enddate.setSeconds(59);
globals.gEndDate = enddate;//This is the global used in form-specific methods
Form-Specific method:
//Call global date-range dialog
globals.sr_DateRange();
if (globals.gStartDate == null || globals.gEndDate == null)// Exit method
{
return;
}
//Format to strip out day-of-week, etc.
var DateStart = utils.dateFormat(globals.gStartDate,‘MM-dd-yyyy HH:mm:ss’);
var DateEnd = utils.dateFormat(globals.gEndDate,‘MM-dd-yyyy HH:mm:ss’);
//Set up/execute search
controller.find();
date1 = DateStart + ‘…’ + DateEnd + ’ |MM-dd-yyyy HH:mm:ss’;
integer1 = ‘>= 1’;
controller.search();
//Sort
controller.sort(‘date1 asc’);
//Go to form (layout)
forms.List3.controller.show();