Skip to content

Latest commit

 

History

History
74 lines (51 loc) · 2.97 KB

File metadata and controls

74 lines (51 loc) · 2.97 KB
title url weight tags
XPath week-from-dateTime
/refguide/xpath-week-from-datetime/
14
studio pro

1 Overview

The week-from-dateTime() function extracts the week number (in the year) from a Date and time attribute so it can be used to compare to a value. Values range from 1 to 53.

{{% alert color="warning" %}} The value returned depends on which database is being used to support your Mendix app. It does NOT take into account the app runtime setting First day of the week.

Many databases implement ISO 8601, but please refer to the documentation for the database you are using to find the exact details. {{% /alert %}}

2 Syntax

The syntax is as follows:

week-from-dateTime ( attribute [, timezone ] )

2.1 attribute

attribute specifies the attribute to extract the day from. Attribute must be of the Date and time type.

2.2 timezone

timezone specifies the time zone to use for the extraction. This parameter is optional and defaults to the local time zone. It should be a string literal containing an IANA time zone or 'UTC'. GMT offset time zones are not supported.

3 Examples

This query returns all the logs where the date DateAttribute falls in the second week of the year in the local time zone (for example, "2011-01-13"):

{{< tabpane >}} {{% tab header="Environments:" disabled=true /%}} {{< tab header="Studio Pro" lang="StudioPro" >}} [week-from-dateTime(DateAttribute) = 2] {{% /tab %}} {{< tab header="Java" lang="JavaQuery" >}} //Logging.Log[week-from-dateTime(DateAttribute) = 2] {{% /tab %}} {{< /tabpane >}}

This query returns all the logs where the date DateAttribute falls in the second week of the year in the New York time zone (for example, "2011-01-13"):

{{< tabpane >}} {{% tab header="Environments:" disabled=true /%}} {{< tab header="Studio Pro" lang="StudioPro" >}} [week-from-dateTime(DateAttribute, 'America/New_York') = 2] {{% /tab %}} {{< tab header="Java" lang="JavaQuery" >}} //Logging.Log[week-from-dateTime(DateAttribute, 'America/New_York') = 2] {{% /tab %}} {{< /tabpane >}}

4 Read More

The following links are for the relevant documentation on how week number is calculated for a specific date for many of the databases used with Mendix.

The HSQLDB database used for testing locally uses JVM's Calendar.WEEK_OF_YEAR.

PostgreSQL, Oracle, and MySQL follow ISO 8601:

Other databases have a more specific behavior: