Introduction
This article documents the basics of using Date and time fields in Dynamics CRM.
Basic Concepts
(1) Dataverse stores all date and time values in the UTC time zone. When the application displays values or processes user-entered values, Dataverse and model-driven applications can use the “Format” option to adjust to the user’s time zone.
(2)When an entity creates a new Date and time'
field, the following format can be selected:
Format | Description |
---|---|
Date only | The date and time values displayed. The time value is stored in the system as 12:00 AM (00:00:00) |
Date and time | Date and time values |

Select Format for ‘Date and time’ fields
(3) When an entity creates a new Date and Time
field, the following Time Zone Adjustment option is available in the Advanced Options.
In addition, the available options for Time Zone Adjustment vary according to the Format as follows:
Format When Date only is selected, Time Zone Adjustment can be selected:
Time Zone Adjustment | Description |
---|---|
User local | Default value. Adjusts the value according to the user’s time zone |
time zone independent | Display values without time zone conversion |
Date only | No time zone conversion. Unlike time zone independence, no time portion is stored ( Time values are stored in the system as 12:00 AM (00:00:00) ) |
Format When Date and time is selected, Time Zone Adjustment can be selected:
Time Zone Adjustment | Description |
---|---|
User local | Default value. Adjusts the value according to the user’s time zone |
Time zone independent | Display values without time zone conversion |
Can Format and Time zone adjustment be changed again?
Is it still possible to modify the format and Time zone adjustment of a Date and time field that has already been created?
The results are verified as follows:
Format and Time Zone Adjustment | Format | Time Zone Adjustment |
---|---|---|
Date only - User local | ✔ | ✔ |
Date only - time zone independent | ✔ | X |
Date only - Date only | X | X |
Date and time - User local | ✔ | ✔ |
Date and time - time zone independent | ✔ | X |
How should I choose the Time zone adjustment?
Time zone adjustment options | Description |
---|---|
Time zone independent | Use this option when time zone information is not required, e.g. hotel check-in time, invoice payment time, etc. When this option is selected, users in all time zones will see the same date and time values |
Date only | Use this option when not focusing on the time of day or time zone, such as birthdays or anniversaries, etc. When this option is selected, users in all time zones will see the exact same date values. |
“Date Only - Time Zone independent is the same as ‘Date Only - Date Only’, and if you are unsure whether the ‘Date and Time’ field will need a time component (hours, minutes, and seconds) in the future, you should Select “Date Only - Time Zone independent.
Since the system defaults to “user local, we need to be careful if we need to select “date only” or “time zone independent” (at least for clear requirements), otherwise Users in different time zones will see different dates due to ±8 hours.
Small experiment
I’ll add the following five new date and time fields to the Invoice entity, assign values to them, and then use them to see the original values stored in the database
- The time zone I’m currently using is
(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi
- The time zone used by user Test06 is
(GMT+04:00) Baku
(1)New Fields
The 5 ‘Date and time’ fields are as follows:
Name | Field Name | Format | Time zone adjustment |
---|---|---|---|
D - User Local | gdh_d_userlocal | Date Only | User local |
D - TZ independent | gdh_d_tz_independent | Date Only | Time zone independent |
D - D | gdh_d_d | Date Only | Date Only |
DT - User Local | gdh_dt_userlocal | Date and time | User local |
DT - TZ independent | gdh_dt_tz_independent | Date and time | Time zone independent |

The 5 ‘Date and time’ fields
(2)Fill in the “Date and Time” field in the form
Assigns a value to a field in the (GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi
time zone:
Field | Fill in a form |
---|---|
D - User Local | 2025-03-10 |
D - TZ independent | 2025-03-12 |
D - D | 2025-03-14 |
DT - User Local | 2025-03-10 14:30 |
DT - TZ independent | 2025-03-24 09:30 |

Fill in the “Date and Time” field in the form
(3)Viewing data in the database

Viewing data in the database
The results are as follows:
Field | Fill in a form | Database value |
---|---|---|
D - User Local | 2025-03-10 | 2025-03-09 16:00:00.000 |
D - TZ independent | 2025-03-12 | 2025-03-12 00:00:00.000 |
D - D | 2025-03-14 | 2025-03-14 00:00:00.000 |
DT - User Local | 2025-03-10 14:30 | 2025-03-10 06:30:00.000 |
DT - TZ independent | 2025-03-24 09:30 | 2025-03-24 09:30:00.000 |
I am assigning D - User Local
in (GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi
time zone, and the time is 2025-03-10.
But in the database, the time is stored in the UTC time zone, and there is an 8 hour time difference between East 8 and UTC.
So the local date of 2025-03-10 becomes 2025-03-09 16:00:00.000 when it is converted to the UTC time zone.
Same for DT - User Local
.
SELECT gdh_d_userlocal AS 'D - User Local',
gdh_d_tz_independent AS 'D - TZ independent',
gdh_d_d AS 'D - D',
gdh_dt_userlocal AS 'DT - User Local',
gdh_dt_tz_independent AS 'DT - TZ independent'
FROM gdh_invoice
WHERE gdh_no = 'SAS-00000001';
(4)Viewing Data with Test06
Note: The time zone used by user Test06 is (GMT+04:00) Baku
.

Viewing Data with Test06
The time stored in the database by D - User Local
is 2025-03-10 06:30:00.000 (UTC time zone).
When this time is converted to the time zone of user Test06: “(GMT+04:00) Baku”, the
the time becomes 2025-03-10 10:30:00.000 (UTC + 4).
So the D - User Local
that user Test06 sees on the form is 2025-03-10 10:30:00.000
(4)Use the Client API to get
a. Get D - User Local
and DT - User Local
value.
Name | Field Names | Format | Time Zone Adjustment | Fill in under GMT+08:00 time zone |
---|---|---|---|---|
D - User Local | gdh_d_userlocal | Date only | User Local | 2025-03-10 |
DT - User Local | gdh_dt_userlocal | Date and time | User Local | 2025-03-10 14:30 |
# 'Sun, 09 Mar 2025 16:00:00 GMT'
Xrm.Page.getAttribute("gdh_d_userlocal").getValue().toUTCString();
# 'Sun, 09 Mar 2025 16:00:00 GMT'
Xrm.Page.getAttribute("gdh_d_userlocal").getValue().toUTCString();
b.For “Time zone independent”, the timezone of the browser is returned
Get D - TZ independent
and DT - TZ independent
value.
Name | Field Names | Format | Time Zone Adjustment |
---|---|---|---|
D - TZ independent | gdh_d_tz_independent | Date only | Timezone independent |
DT - TZ independent | gdh_dt_tz_independent | Date and time | Timezone independent |
# 'Wed Mar 12 2025 00:00:00 GMT+0800 (China Standard Time)'
Xrm.Page.getAttribute("gdh_d_tz_independent").getValue().toString();
# 'Mon Mar 24 2025 09:30:00 GMT+0800 (China Standard Time)'
Xrm.Page.getAttribute("gdh_dt_tz_independent").getValue().toString();
JavaScript date values are affected by the browser’s time zone (from the device OS settings), so care should be taken:
for the field “User Local Time”, the Client API gets the result as a “UTC” value and should use
Date.getUTCDate()
,Date.getUTCHours()
instead ofDate.getDate()
.apply
getTimeZoneOffsetMinutes
if you want to get the time the user sees. Don’t useDate.getDate()
,Date.getHours()
, etc., as they show the browser’s timezoneFor “timezone-independent” and “date-only” fields, you should use
Date.getDate()
,Date.getHours()
, etc., instead ofDate.getUTCDate()
,Date.getUTCHours()
, as there is no need for timezone conversion.
(5)Using Web API to Retrieve Data
Assign values to fields in the (GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi timezone and retrieve them using a Web API:
Field | Input Value | Stored Value in Database | Retrieved via Web API |
---|---|---|---|
D - User Local | 2025-03-10 | 2025-03-09 16:00:00.000 | 2025-03-09T16:00:00Z |
D - TZ independent | 2025-03-12 | 2025-03-12 00:00:00.000 | 2025-03-12T00:00:00Z |
D - D | 2025-03-14 | 2025-03-14 00:00:00.000 | 2025-03-14 |
DT - User Local | 2025-03-10 14:30 | 2025-03-10 06:30:00.000 | 2025-03-10T06:30:00Z |
DT - TZ independent | 2025-03-24 09:30 | 2025-03-24 09:30:00.000 | 2025-03-24T09:30:00Z |
It can be observed that the raw value retrieved via the Web API is the same as the value stored in the database.
What do “T” and “Z” mean in “gdh_dt_userlocal”: “2025-03-10T06:30:00Z”?
T
- “T” is a special character in the ISO 8601 datetime format used to separate the date and time parts.
- For example, 2025-03-10T14:30:00 represents March 10, 2025, at 14:30:00.
Z
- “Z” is a special character in the ISO 8601 datetime format, representing “Zulu time” or UTC (Coordinated Universal Time).
- It indicates that the time is expressed in UTC with no time zone offset.
- For example, 2025-03-10T14:30:00Z represents March 10, 2025, at 14:30:00 (UTC time).
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v9.1/gdh_invoices(98F83878-1E35-EF11-8409-0017FA0671FA)?$select=gdh_d_d,gdh_d_tz_independent,gdh_d_userlocal,gdh_dt_tz_independent,gdh_dt_userlocal", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function() {
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 200) {
var result = JSON.parse(this.response);
var gdh_d_d = result["gdh_d_d"];
var gdh_d_tz_independent = result["gdh_d_tz_independent"];
var gdh_d_userlocal = result["gdh_d_userlocal"];
var gdh_dt_tz_independent = result["gdh_dt_tz_independent"];
var gdh_dt_userlocal = result["gdh_dt_userlocal"];
} else {
Xrm.Utility.alertDialog(this.statusText);
}
}
};
req.send();
Query Operators Not Supported?
For “date-only” type date and time fields, the following query operators are not allowed. Using these operators in queries will result in an invalid operator exception error.
- X minutes ago
- X hours ago
- Past X hours
- Next X hours
For example, when filtering the “D-D” column, the filter conditions are as follows:
<condition attribute="gdh_d_d" operator="last-x-hours" value="5"/>

filtering the D-D column
An error is reported after execution:2147779605The operator is not valid or it is not supported.

Error:2147779605The operator is not valid or it is not supported.
How to Set the User’s Time Zone?
Click the Settings button in the top right corner –> Personalization Settings –> General Tab –> Select Time Zone.

Set the User’s Time Zone
Thank you for your patience in reading! Come pick an emoji or leave a comment!