Hello, I have a quick question. Why are my date f...
# suitescript
p
Hello, I have a quick question. Why are my date filters returning a null value? filters[1] = search.createFilter({ name:'custrecord_pi_startdate', operator: search.Operator.ONORAFTER,values: responseDate }); filters[2] = search.createFilter({ name:'custrecord_pi_enddate', operator: search.Operator.ONORBEFORE,values: responseDate });
b
what is the value of responseDate
p
4/26/2021
the debugger is showing a value
b
that looks like a string
is it a string or a date
p
I format responseDate as a date
b
i still dont know what it is
p
var responseDate=format.format({valuetrandate,typeformat.Type.DATE});
b
and the value of trandate
you can probably guess at this point that variables are useless to me for debugging purposes
p
message has been deleted
and custrecord_pi_startdate is a date field on the custom record
b
that looks like a string
p
ok. how can I convert it to a proper date?
b
a string looks like var responseDate = "4/26/2021"
a date looks like var responseDate = new Date()
if you think you are having problems with filter values, you should start from hardcoded values
and then move onto something more useful
p
when I do convert to a date I get Invalid date value Mon Apr 26 2021 000000 GMT-0700 (PDT) (must match M/d/yy)
b
thats normal, search filters want strings
p
is there anything else I can try? I am trying to compare against the start and end date on the custom record
b
which record is it supposed to find
p
the one where the ratio is 1.0, the start date is 4/1/2021 and the end date is 03/31/2022
I have another record where the ratio is 1.0, start date is 4/1/2020 and the end date is 03/31/2021
b
your first filter is
Copy code
search.createFilter({ name:'custrecord_pi_startdate', operator: search.Operator.ONORAFTER,values: "4/26/2021"});
4/1/2021 is not on or after 4/26/2021
p
whoops
thanks for your help