I am running into a weird issue with N/format. I ...
# suitescript
s
I am running into a weird issue with N/format. I am getting the error
INVALID_TYPE_1_USE_2 - Invalid type NAN, use Date
. Here is the code below. getMomentDate(value) returns "1/13/2021". Any idea why?
Copy code
var date = format.format({
    value: getMomentDate(value),
    type: "date"
});
s
"1/13/2021" is already a string, what are you trying to do with format.format ? Do you need to convert the date string to a different format?
s
nah, it's making sure it is a date so that I can set it
s
Usually, you would either use 
format.parse
, or 
new Date()
 to convert a string to a Date, or using a library like Moment.js, which can convert a moment object to a Date with 
momentObj.toDate()
100 Views