title | titleSuffix | description | author | ms.author | ms.reviewer | ms.service | ms.subservice | ms.topic | ms.devlang | ms.date | ms.custom |
---|---|---|---|---|---|---|---|---|---|---|---|
GetCurrentTimestampStatic |
Azure Cosmos DB for NoSQL |
An Azure Cosmos DB for NoSQL system function that returns a static timestamp value. |
jcodella |
jacodel |
sidandrews |
cosmos-db |
nosql |
reference |
nosql |
02/27/2024 |
query-reference |
[!INCLUDENoSQL]
Returns the number of milliseconds that have elapsed since 00:00:00 Thursday, 1 January 1970
.
Important
The static variation of this function only retrieves the timestamp once per partition. For more information on the non-static variation, see GetCurrentTimestamp
GetCurrentTimestampStatic()
Returns a signed numeric value that represents the current number of milliseconds that have elapsed since the Unix epoch (00:00:00 Thursday, 1 January 1970
).
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.
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/getcurrenttimestampstatic/seed.novalidate.json" highlight="4,8,12":::
This function returns the same static timestamp for items within the same partition. For comparison, the nonstatic function gets a new timestamp value for each item matched by the query.
:::code language="nosql" source="~/cosmos-db-nosql-query-samples/scripts/getcurrenttimestampstatic/query.novalidate.sql" highlight="4-5":::
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/getcurrenttimestampstatic/result.novalidate.json":::
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.
- 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.