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.

Rookie Asked on March 30, 2021 in SuiteScript.
Add Comment
1 Answer(s)

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;

 

Rookie Answered on July 15, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor   Become a Sponsor