How do I do a search filtered by date AND time?
This works:
var dt = format.format({type: format.Type.DATE, value: new Date()}); search.create({ type: "supportcase", filters: [['lastmodifieddate', search.Operator.AFTER, dt]], columns: ["internalid"] }).run().getRange(0, 1000);
But this results in UNEXPECTED_ERROR:
var dt = format.format({type: format.Type.DATETIME, value: new Date()}); search.create({ type: "supportcase", filters: [['lastmodifieddate', search.Operator.AFTER, dt]], columns: ["internalid"] }).run().getRange(0, 1000);
format.Type.DATETIMETZ also causes UNEXPECTED_ERROR.
Date isn’t enough, I need to filter by date AND time. After several years with NS I shouldn’t be surprised at how difficult this is, but I am.
This is actually a defect on Netsuite’s side.
The workaround I have found is to concatenate the result of the format function with options DATE and TIMEOFDAY with a space in between. Here is an example:
var date = new Date(); var dateString = format.format({ value: date, type: format.Type.DATE }); var timeString = format.format({ value: date, type: format.Type.TIMEOFDAY }); var dt = dateString + ' ' + timeString;