Felix Divall
10/03/2023, 8:38 AMtrandate: Fri Oct 13 2023 00:00:00 GMT-0700 (PDT)
const date = new Date(extractedValue)
const dateValue = format.parse({ value: format.format({ value: new Date(date.getTime() + (7 * 3600000)), type: format.Type.DATE }), type: format.Type.DATE })
log.debug('DATE VALUE', `${key}: ${dateValue}`)
rec.setValue({ fieldId: key, value: dateValue })
battk
10/03/2023, 9:22 AMconst date = new Date(extractedValue)
battk
10/03/2023, 9:23 AMbattk
10/03/2023, 9:24 AMbattk
10/03/2023, 9:26 AMnew Date(date.getTime() + (7 * 3600000))
which will essentially make a new Date, 7 hours in the futurebattk
10/03/2023, 9:26 AMbattk
10/03/2023, 9:28 AMformat.format({ value: new Date(date.getTime() + (7 * 3600000)), type: format.Type.DATE })
which will convert the date to a string in your user's date format, in this case probably something like 2013-10-13
battk
10/03/2023, 9:29 AMbattk
10/03/2023, 9:30 AMbattk
10/03/2023, 9:32 AMconst dateValue = format.parse({ value: format.format({ value: new Date(date.getTime() + (7 * 3600000)), type: format.Type.DATE }), type: format.Type.DATE })
although it makes more sense as
const dateValue = format.parse({ value: '2013-10-13', type: format.Type.DATE })
which will generate a a date representing 2013-10-13
at midnight in pacific time since netsuite date's dont care about time on timezonebattk
10/03/2023, 9:33 AMFri Oct 13 2023 00:00:00 GMT-0700 (PDT)
is 2013-10-13
at midnightFelix Divall
10/03/2023, 9:45 AMbattk
10/03/2023, 9:48 AMbattk
10/03/2023, 9:49 AMFelix Divall
10/03/2023, 9:49 AMbattk
10/03/2023, 9:49 AMbattk
10/03/2023, 9:54 AMbattk
10/03/2023, 9:54 AMFelix Divall
10/03/2023, 9:55 AMconst dateValue = format.parse({ value: format.format({ value: new Date(extractedValue), type: format.Type.DATE, timezone: format.Timezone.EUROPE_KIEV }), type: format.Type.DATE, timezone: format.Timezone.EUROPE_KIEV })
But I still get PDTbattk
10/03/2023, 9:57 AMbattk
10/03/2023, 9:58 AMbattk
10/03/2023, 9:58 AMFelix Divall
10/03/2023, 9:58 AMconst date = new Date(extractedValue)
log.debug(‘date’, date) = “2023-10-13T000000.000Z”
log.debug(‘DATE VALUE’, ${key}: ${date}
) = trandate: Thu Oct 12 2023 170000 GMT-0700 (PDT)Felix Divall
10/03/2023, 9:59 AMFelix Divall
10/03/2023, 9:59 AMbattk
10/03/2023, 10:03 AMbattk
10/03/2023, 10:06 AMFelix Divall
10/03/2023, 10:13 AMbattk
10/03/2023, 10:25 AMbattk
10/03/2023, 10:25 AM"2023-10-03T13:25:18+03:00"
battk
10/03/2023, 10:26 AMbattk
10/03/2023, 10:27 AMFelix Divall
10/03/2023, 11:29 AMNElliott
10/03/2023, 11:32 AMFelix Divall
10/03/2023, 11:33 AMFelix Divall
10/03/2023, 11:34 AMextracedValue
is 2023-10-13
const dateValue = format.parse({ value: extractedValue, type: format.Type.DATE })
log says trandate: 2023-10-13
Felix Divall
10/03/2023, 11:34 AMerror: Invalid date value (must be DD.MM.YYYY) Field: trandate
Felix Divall
10/03/2023, 11:34 AMtrandate: Thu Oct 12 2023 17:00:00 GMT-0700 (PDT)
NElliott
10/03/2023, 11:35 AMFelix Divall
10/03/2023, 11:36 AMNElliott
10/03/2023, 11:36 AMFelix Divall
10/03/2023, 11:36 AMFelix Divall
10/03/2023, 11:36 AMNElliott
10/03/2023, 11:37 AMNElliott
10/03/2023, 11:37 AMFelix Divall
10/03/2023, 11:37 AMconst dateValue = format.parse({ value: extractedValue, type: format.Type.DATE })
This gave me the errorNElliott
10/03/2023, 11:39 AMFelix Divall
10/03/2023, 11:39 AMFelix Divall
10/03/2023, 11:39 AMbattk
10/03/2023, 3:05 PMbattk
10/03/2023, 3:06 PMbattk
10/03/2023, 3:22 PM2023-10-13
will be interpreted as gmt time, so its midnight gmtbattk
10/03/2023, 3:24 PM2023-10-13T00:00:00+00:00
, which when converted to pacific time, is 2023-10-12T17:00:00+00:00-7:00
, hence the being off by 1 hourerictgrubaugh
10/03/2023, 3:25 PMfunction _asTimestamp(datetime) {
const endOfDay = datetime.replace('0:00:00', '23:59:59');
return new Date(`${endOfDay}Z`).getTime();
}
// _asTimestamp('2023-10-03T0:00:00') => 1696377599000
erictgrubaugh
10/03/2023, 3:26 PMerictgrubaugh
10/03/2023, 3:26 PMbattk
10/03/2023, 3:27 PMnew Date(date.getTime() + (7 * 3600000))
works (although you will want to use a number greater than 7 hours when standard time comes around)battk
10/03/2023, 3:33 PMbattk
10/03/2023, 3:33 PMNElliott
10/03/2023, 4:28 PMbattk
10/03/2023, 4:31 PMnew Date('2023-10-13')
NElliott
10/03/2023, 4:32 PMbattk
10/03/2023, 4:32 PMerictgrubaugh
10/03/2023, 4:39 PMnew Date()
part is what's going to take off 7 hours; so the 7 (or 8 or whatever offset) will be removed before you could setHours()
on iterictgrubaugh
10/03/2023, 4:40 PMDate
erictgrubaugh
10/03/2023, 4:41 PMDate
and adjust it by adding or subtracting the offset hours as appropriate, but just setting the hours will not workNElliott
10/04/2023, 7:20 AM