Thursday, May 9, 2019

Understanding Date fields in Web Services

When setting a date field using web services, a datetime value must be entered. The time and time zone following the date are used to determine the resulting date. When getting the date field through web services, the user's preferred time zone influences the resulting datetime, i.e. midnight in the user's time zone of the stored date (which is also displayed in the UI) is converted to the PST/PDT and sent to the web services user.

The following table gives several examples:

 Datetime set in date field

 Time Zone of the User

 Date shown in UI

 Datetime when getting the record2

 2013-02-21T00:00:00.000-06:00 GMT-06:00 2/21/2013 2013-02-20T22:00:00.000-08:00 
 2013-08-21T00:00:00.000-05:00  GMT-05:001 8/21/2013 2013-08-20T22:00:00.000-07:00
 2013-02-21T00:00:00.000-05:00 GMT-08:00 2/20/20133 2013-02-20T00:00:00.000-08:00
 2013-08-21T00:00:00.000-07:00 GMT-05:001 8/21/2013 2013-08-20T22:00:00.000-07:00

Notes for example table:

  1. The user has set their time zone to GMT-6, but the DST affects the result.
  2. This is midnight of the date from the UI that is converted to the PST/PDT. Please note the time difference, which equals the difference between the user's preferred time zone and the PST/PDT.
  3. The datetime which is to be saved is not greater than midnight in the user's preferred time zone.


  • To avoid problems with conversions, set the time zone of the web services employee to "(GMT-08:00) Pacific Time (US & Canada)" in Home > Set Preferences. Also, submit the datetimes for date fields as midnight and in PST/PDT (see the Setting Proper Date/Time section below). Doing this will result in no conversions or truncations (what is submitted will be identical to what is retrieved with web services).
  • When changing time zone preferences the user must re-log using web services for the change to take effect. If the same session is used the old time zone will be used as well. Caching may also occur for a period after changing time zones.
  • Users setting the field value need to pay attention to the DST offset, as it influences the decision point (midnight of user's time zone) according to which value is set to the field.
  • If the time zone specified in set field request is different than the time zone of the user setting the field, the datetime is first converted to the time zone of the user and the date portion is stored. The time is then set to midnight and returned in PST.  See the second row of the table for an example.

Setting Proper Date/Time Format for SuiteTalk (Web Services)

Setting of Date Time, Date or Time fields for Web Services using Date-Time-Timezone:

If the user does not indicate the Timezone on the request the Netsuite, will use its own system Timezone (PST UTC-8/PDT UTC-07):

Users can indicate an UTC Timezone by adding the 'Z' character at the end of the DateTime Format:

No comments:

Post a Comment