GetCurrentDateTimeStatic (NoSQL query)

APPLIES TO: NoSQL

Returns the current UTC (Coordinated Universal Time) date and time as an ISO 8601 string.

Important

The static variation of this function only retrieves the date and time once per partition. For more information on the non-static variation, see GetCurrentDateTime

Syntax

GetCurrentDateTimeStatic()

Return types

Returns the current UTC date and time string value in the round-trip (ISO 8601) format.

Note

For more information on the round-trip format, see .NET round-trip format.

Examples

This example uses a container with a partition key path of /pk. There are three items in the container with two items within the same logical partition, and one item in a different logical partition.

[
  {
    "id": "1",
    "pk": "A"
  },
  {
    "id": "2",
    "pk": "A"
  },
  {
    "id": "3",
    "pk": "B"
  }
]

This function returns the same static date and time for items within the same partition. For comparison, the nonstatic function gets a new date and time value for each item matched by the query.

SELECT
    i.id,
    i.pk AS partitionKey,
    GetCurrentDateTime() AS nonStaticDateTime,
    GetCurrentDateTimeStatic() AS staticDateTime
FROM
    items i
[
  {
    "id": "1",
    "partitionKey": "A",
    "nonStaticDateTime": "2023-06-28T18:32:12.4500994Z",
    "staticDateTime": "2023-06-28T18:32:12.4499507Z"
  },
  {
    "id": "2",
    "partitionKey": "A",
    "nonStaticDateTime": "2023-06-28T18:32:12.4501101Z",
    "staticDateTime": "2023-06-28T18:32:12.4499507Z"
  },
  {
    "id": "3",
    "partitionKey": "B",
    "nonStaticDateTime": "2023-06-28T18:32:12.4501181Z",
    "staticDateTime": "2023-06-28T18:32:12.4401181Z"
  }
]

Note

It's possible for items in different logical partitions to exist in the same physical partition. In this scenario, the static date and time value would be identical.

Remarks

  • This static function is called once per partition.
  • Static versions of system functions only get their respective values once during binding, rather than execute repeatedly in the runtime as is the case for the nonstatic versions of the same functions.

See also