HOW TO: Work with and search date fields

The code below

//findPreviouslyEntered[TEEntry]
// This method will retrieve all of the entry records
globals.setFromToDates(1); // generates globals.fromdate and globals.todate to be Yesterday and today respectively
var d1 = utils.dateFormat(globals.fromdate, ‘MM-dd-yyyy’);
var d2 = utils.dateFormat(globals.todate, ‘MM-dd-yyyy’);
controller.find();
//userentering = security.getUserName()
dateentered = d1+‘…’ + d2+‘|MM-dd-yyyy’ ;
controller.search();

will only find dates with dateentered with the from date (yesterday). It will not find any records that are equal to the todate (today)

After checking the actual values for dateentered in the table they all have a hh:mm:ss value of ‘12:00:00’

after trying the following:

//findPreviouslyEntered[TEEntry]
// This method will retrieve all of the entry records
globals.setFromToDates(1); // generates globals.fromdate and globals.todate to be Yesterday and today respectively
var d1 = utils.dateFormat(globals.fromdate, ‘MM-dd-yyyy hh:mm:ss’);
d1.setHours(00);
d1.setMinutes(00);
d1.setSeconds(00);
var d2 = utils.dateFormat(globals.todate, ‘MM-dd-yyyy hh:mm:ss’);
d2.setHours(23);
d2.setMinutes(59);
d2.setSeconds(59);
controller.find();
//userentering = security.getUserName();
dateentered = d1+‘…’ + d2+‘|MM-dd-yyyy hh:mm:ss’ ;
controller.search();

I get an error stating that “setHours is not a function”

Any suggestions?