Can I get a pointer on best way to solve a date is...
# suitescript
n
Can I get a pointer on best way to solve a date issue. In my script I have a search returning a transaction date from a saved search. it gets compared to a date from another saved search. One is coming back as PDT & one as GMT. I want to update a record when the dates are different and when different I want to calculate the difference. I was thinking n/format would be the way to convert the dates:
var parsedDateStringAsRawDateObject = format.format({
value	: dateText,
type	: format.Type.DATETIME,
timezone: format.Timezone.AUSTRALIA_SYDNEY
});
I do get values but when I do date1 - date2 I get Nan as the result. newValue:1/11/2021- oldValue:28/1/2022 = NaN
b
you want to make sure that
parsedDateStringAsRawDateObject
is actually a Date
one of the weaknesses of N/format is that invalid inputs return the input instead of throwing an Error
n
you are onto it.
b
I can't really be sure from what you have given, but it looks like you only have the date part of the date time string
n
on this one I was trying something. usually it looks like newValue:Sat Nov 27 2021 000000 GMT-0800 (PST)- oldValue:Wed Sep 29 2021 000000 GMT
b
still dont know enough from what is shared
that new value might be something that comes from a Date, the old value does not
you would need to share your code
and your searches