You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more information on `DATETIME` values, see the [example section under *DATEPART*](#oql-datepart-example), below.
880
881
881
882
##### startdate_expression
@@ -888,7 +889,11 @@ For more information on `DATETIME` values, see the [example section under *DATEP
888
889
889
890
##### timezone
890
891
891
-
`timezone` specifies the time zone to use for the retrieval. This parameter is optional and defaults to the local time zone. It should be a string literal containing an [IANA time zone](https://www.iana.org/time-zones). GMT offset time zones are not supported.
892
+
`timezone` specifies the time zone to use for the retrieval. This parameter is optional and defaults to the user time zone. It should be a string literal containing an [IANA time zone](https://www.iana.org/time-zones). GMT offset time zones are not supported.
893
+
894
+
{{% alert color="info" %}}
895
+
The user time zone is usually different from UTC. To get the result in the UTC time zone, explicitly specify `'UTC'` in this parameter. For details on time zone handling in Mendix Runtime, see [Date and Time Handling](/refguide/date-and-time-handling/).
`timezone` specifies the time zone to use for the retrieval. This parameter is optional and defaults to the local time zone. It should be a string literal containing an IANA time zone. GMT offset time zones are not supported.
961
+
`timezone` specifies the time zone to use for the retrieval. This parameter is optional and defaults to the user time zone. It should be a string literal containing an IANA time zone. GMT offset time zones are not supported.
962
+
963
+
{{% alert color="info" %}}
964
+
The user time zone is usually different from UTC. To get the result in the UTC time zone, explicitly specify `'UTC'` in this parameter. For details on time zone handling in Mendix Runtime, see [Date and Time Handling](/refguide/date-and-time-handling/).
965
+
{{% /alert %}}
957
966
958
967
#### Examples{#oql-datepart-example}
959
968
@@ -981,6 +990,74 @@ SELECT End FROM Sales.Period WHERE DATEPART(YEAR, End) = 2025
981
990
|---------------------|
982
991
| 2025-07-05 00:00:00 |
983
992
993
+
### DATETRUNC {#datetrunc-function}
994
+
995
+
The `DATETRUNC` function truncates a `DATETIME` value to a specified datepart. The return type is `DATETIME`.
996
+
997
+
This function was introduced in Mendix version 11.9.0
`datepart` specifies the part to which the `DATETIME` value is truncated. For possible values, see the [Example](#oql-datetrunc-example) below.
1010
+
1011
+
##### date_expression
1012
+
1013
+
`date_expression` specifies the date to retrieve an element from. The expression should resolve to a `DATETIME` value. String representations of `DATETIME` are accepted.
1014
+
1015
+
##### timezone
1016
+
1017
+
`timezone` specifies the time zone to use for truncation. This parameter is optional and defaults to the user time zone. It should be a string literal containing an IANA time zone. GMT offset time zones are not supported.
1018
+
1019
+
{{% alert color="info" %}}
1020
+
The user time zone is usually different from UTC. To get the result in the UTC time zone, explicitly specify `'UTC'` in this parameter. For details on time zone handling in Mendix Runtime, see [Date and Time Handling](/refguide/date-and-time-handling/).
1021
+
{{% /alert %}}
1022
+
1023
+
#### Examples{#oql-datetrunc-example}
1024
+
1025
+
| datepart | Truncation result for `2005-09-03T16:34:20.356`|
Date part types `DAYOFYEAR`, `WEEKDAY` and `MILLISECOND` are not supported by the `DATETRUNC` function
1038
+
{{% /alert %}}
1039
+
1040
+
{{% alert color="info" %}}
1041
+
For the date part type `WEEK`, the result of the `DATETRUNC` function depends on the database configuration. For example, by default, the first day of the week in MS SQL Server is Sunday, which means that dates are truncated to previous Sunday if date part type `WEEK` is used.
1042
+
{{% /alert %}}
1043
+
1044
+
`DATETRUNC` function can be used to group data by time periods:
0 commit comments