Hi, ``` var est_date = format.format({...
# suitescript
g
Hi,
Copy code
var est_date = format.format({
                value: datetoSet,
                type: format.Type.DATE,
                timezone: format.Timezone.AMERICA_NEWYORK
            })

            rec.setText({
                fieldId: 'custbody_sps_shipstatusdate_870',
                value: est_date//format.parse(est_date, format.Type.MMYYDATE)
            });
I need the date to be formatted as MDYYYY (per the error I got) Right now nothing is being saved. Can anyone help me here?
a
what are you passing in to format.format? what is
datetoSet
? a string? a date object? I'd log it first to be sure it is what you think it is.
Copy code
log.debug({
   title:  'datetoSet variable'
   details: datetoSet
});
I'd also log the est_date in the same way when it comes out of format but before it goes into the setText just to see if its actually null, or if its somehow not what that field is expecting.
b
pay closer attention to the documentation on Record.setValue and Record.setText
they use different parameters and require different types for their parameters
g
It looks like my date is the correct format
b
you swapped to using setValue, so what type of value does the documentation say to put into the value parameter
g
the same datatype as the field - which it is
b
be more specific
what type of value should be used as the value for a date field
g
Date and DateTime fields accept Date values
actually-
Copy code
var est_date = format.format({
                value: datetoSet,
                type: format.Type.DATE,
                timezone: format.Timezone.AMERICA_NEWYORK
           })
Does not return a date apparently
b
correct, and now we are onto, what does format.format output
g
a string
so one i do that and get the correct Timezone, i can jsut do est_date = new Date(est_date); and then it will be a date and i can save
makes sense
or is that redundant coding?
b
redundant
you are starting with a date, converting it into a string that you cant use
and then trying to convert it back into a date again
g
I need to force it to be EST
how do i do that and keep it a Date
b
thats not how dates work, in netsuite nor javascript
the timezone is irrelevant to a netsuite date, its always pacific time
the local timezone used by the javascript engine is also using pacific time
g
so if i want to check if a time is before noon on EST
then I have to subtract the housrs? and check it?
b
its probably easier to just work in pacific time, in which its before 9 am pacific
g
thanks 🙂
b
theoretically 3 hour difference is not strictly true on leap days or leap seconds
but noon wont be affected by those
g
Thanks @battk!