Skip to content

Commit 76b4490

Browse files
committed
Add GetCurrentDateTime, GetCurrentTicks, and GetCurrentTimestamp
1 parent c1799b1 commit 76b4490

File tree

6 files changed

+95
-118
lines changed

6 files changed

+95
-118
lines changed
Lines changed: 31 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,52 @@
11
---
2-
title: GetCurrentDateTime in Azure Cosmos DB query language
3-
description: Learn about SQL system function GetCurrentDateTime in Azure Cosmos DB.
4-
author: seesharprun
2+
title: GetCurrentDateTime
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns an ISO 8601 date and time value.
5+
author: jcodella
6+
ms.author: jacodel
7+
ms.reviewer: sidandrews
58
ms.service: cosmos-db
69
ms.subservice: nosql
7-
ms.topic: conceptual
8-
ms.date: 02/03/2021
9-
ms.author: sidandrews
10-
ms.reviewer: jucocchi
11-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/19/2023
12+
ms.custom: query-reference
1213
---
13-
# GetCurrentDateTime (Azure Cosmos DB)
14+
15+
# GetCurrentDateTime (NoSQL query)
16+
1417
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1518

1619
Returns the current UTC (Coordinated Universal Time) date and time as an ISO 8601 string.
17-
20+
1821
## Syntax
19-
22+
2023
```sql
21-
GetCurrentDateTime ()
24+
GetCurrentDateTime()
2225
```
2326

2427
## Return types
25-
26-
Returns the current UTC date and time ISO 8601 string value in the format `YYYY-MM-DDThh:mm:ss.fffffffZ` where:
27-
28-
|Format|Description|
29-
|-|-|
30-
|YYYY|four-digit year|
31-
|MM|two-digit month (01 = January, etc.)|
32-
|DD|two-digit day of month (01 through 31)|
33-
|T|signifier for beginning of time elements|
34-
|hh|two-digit hour (00 through 23)|
35-
|mm|two-digit minutes (00 through 59)|
36-
|ss|two-digit seconds (00 through 59)|
37-
|.fffffff|seven-digit fractional seconds|
38-
|Z|UTC (Coordinated Universal Time) designator|
39-
40-
For more information on the ISO 8601 format, see [ISO_8601](https://en.wikipedia.org/wiki/ISO_8601)
4128

42-
## Remarks
43-
44-
GetCurrentDateTime() is a nondeterministic function. The result returned is UTC. Precision is 7 digits, with an accuracy of 100 nanoseconds.
29+
Returns the current UTC date and time string value in the **round-trip** (ISO 8601) format.
4530

4631
> [!NOTE]
47-
> This system function will not utilize the index. If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
32+
> For more information on the round-trip format, see [.NET round-trip format](/dotnet/standard/base-types/standard-date-and-time-format-strings#the-round-trip-o-o-format-specifier). For more information on the ISO 8601 format, see [ISO 8601](https://wikipedia.org/wiki/ISO_8601).
4833
4934
## Examples
50-
51-
The following example shows how to get the current UTC Date Time using the GetCurrentDateTime() built-in function.
52-
53-
```sql
54-
SELECT GetCurrentDateTime() AS currentUtcDateTime
55-
```
56-
57-
Here is an example result set.
58-
59-
```json
60-
[{
61-
"currentUtcDateTime": "2019-05-03T20:36:17.1234567Z"
62-
}]
63-
```
35+
36+
The following example shows how to get the current UTC date and time string.
37+
38+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/getcurrentdatetime/query.novalidate.sql" highlight="2":::
39+
40+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/getcurrentdatetime/result.novalidate.json":::
41+
42+
## Remarks
43+
44+
- This function is nondeterministic.
45+
- The result returned is UTC (Coordinated Universal Time) with precision of seven digits and an accuracy of 100 nanoseconds.
46+
- This function doesn't use the index.
47+
- If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
6448

6549
## Next steps
6650

6751
- [System functions Azure Cosmos DB](system-functions.yml)
68-
- [Introduction to Azure Cosmos DB](../../introduction.md)
52+
- [`GetCurrentDateTimeStatic`](getcurrentdatetimestatic.md)

articles/cosmos-db/nosql/query/getcurrentdatetimestatic.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ GetCurrentDateTimeStatic()
2929

3030
## Return types
3131

32-
Returns the current UTC date and time string value in the **round-trip** (ISO 8601) format. For more information on the round-trip format, see [.NET round-trip format](/dotnet/standard/base-types/standard-date-and-time-format-strings#the-round-trip-o-o-format-specifier). For more information on the ISO 8601 format, see [ISO 8601](https://wikipedia.org/wiki/ISO_8601).
32+
Returns the current UTC date and time string value in the **round-trip** (ISO 8601) format.
33+
34+
> [!NOTE]
35+
> For more information on the round-trip format, see [.NET round-trip format](/dotnet/standard/base-types/standard-date-and-time-format-strings#the-round-trip-o-o-format-specifier). For more information on the ISO 8601 format, see [ISO 8601](https://wikipedia.org/wiki/ISO_8601).
3336
3437
## Examples
3538

@@ -54,4 +57,4 @@ This function returns the same static date and time for items within the same pa
5457
## See also
5558

5659
- [System functions](system-functions.yml)
57-
- [`GetCurrentDateTime` (nonstatic)](getcurrentdatetime.md)
60+
- [`GetCurrentDateTime`](getcurrentdatetime.md)
Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,49 @@
11
---
2-
title: GetCurrentTicks in Azure Cosmos DB query language
3-
description: Learn about SQL system function GetCurrentTicks in Azure Cosmos DB.
4-
author: seesharprun
2+
title: GetCurrentTicks
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns a nanosecond ticks value.
5+
author: jcodella
6+
ms.author: jacodel
7+
ms.reviewer: sidandrews
58
ms.service: cosmos-db
69
ms.subservice: nosql
7-
ms.topic: conceptual
8-
ms.date: 02/03/2021
9-
ms.author: sidandrews
10-
ms.reviewer: jucocchi
11-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/19/2023
12+
ms.custom: query-reference
1213
---
13-
# GetCurrentTicks (Azure Cosmos DB)
14+
15+
# GetCurrentTicks (NoSQL query)
16+
1417
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1518

16-
Returns the number of 100-nanosecond ticks that have elapsed since 00:00:00 Thursday, 1 January 1970.
19+
Returns the number of 100-nanosecond ticks that have elapsed since `00:00:00 Thursday, 1 January 1970`.
1720

1821
## Syntax
1922

2023
```sql
21-
GetCurrentTicks ()
24+
GetCurrentTicks()
2225
```
2326

2427
## Return types
2528

26-
Returns a signed numeric value, the current number of 100-nanosecond ticks that have elapsed since the Unix epoch. In other words, GetCurrentTicks returns the number of 100 nanosecond ticks that have elapsed since 00:00:00 Thursday, 1 January 1970.
29+
Returns a signed numeric value that represents the current number of 100-nanosecond ticks that have elapsed since the Unix epoch (`00:00:00 Thursday, 1 January 1970`).
2730

28-
## Remarks
29-
30-
GetCurrentTicks() is a nondeterministic function. The result returned is UTC (Coordinated Universal Time).
31+
## Examples
3132

32-
> [!NOTE]
33-
> This system function will not utilize the index. If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
33+
The following example returns the current time measured in ticks:
3434

35-
## Examples
35+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/getcurrentticks/query.novalidate.sql" highlight="2":::
3636

37-
Here's an example that returns the current time, measured in ticks:
37+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/getcurrentticks/result.novalidate.json":::
3838

39-
```sql
40-
SELECT GetCurrentTicks() AS CurrentTimeInTicks
41-
```
39+
## Remarks
4240

43-
```json
44-
[
45-
{
46-
"CurrentTimeInTicks": 15973607943002652
47-
}
48-
]
49-
```
41+
- This function is nondeterministic.
42+
- The result returned is UTC (Coordinated Universal Time).
43+
- This function doesn't use the index.
44+
- If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
5045

5146
## Next steps
5247

5348
- [System functions Azure Cosmos DB](system-functions.yml)
54-
- [Introduction to Azure Cosmos DB](../../introduction.md)
49+
- [`GetCurrentTicksStatic`](getcurrentticksstatic.md)

articles/cosmos-db/nosql/query/getcurrentticksstatic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ This function returns the same static nanosecond ticks for items within the same
5454
## See also
5555

5656
- [System functions](system-functions.yml)
57-
- [`GetCurrentTicks` (nonstatic)](getcurrentticks.md)
57+
- [`GetCurrentTicks`](getcurrentticks.md)
Lines changed: 32 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,49 @@
11
---
2-
title: GetCurrentTimestamp in Azure Cosmos DB query language
3-
description: Learn about SQL system function GetCurrentTimestamp in Azure Cosmos DB.
4-
author: seesharprun
2+
title: GetCurrentTimestamp
3+
titleSuffix: Azure Cosmos DB for NoSQL
4+
description: An Azure Cosmos DB for NoSQL system function that returns a timestamp value.
5+
author: jcodella
6+
ms.author: jacodel
7+
ms.reviewer: sidandrews
58
ms.service: cosmos-db
69
ms.subservice: nosql
7-
ms.topic: conceptual
8-
ms.date: 02/03/2021
9-
ms.author: sidandrews
10-
ms.reviewer: jucocchi
11-
ms.custom: query-reference, ignite-2022
10+
ms.topic: reference
11+
ms.date: 07/19/2023
12+
ms.custom: query-reference
1213
---
13-
# GetCurrentTimestamp (Azure Cosmos DB)
14+
15+
# GetCurrentTimestamp (NoSQL query)
16+
1417
[!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
1518

16-
Returns the number of milliseconds that have elapsed since 00:00:00 Thursday, 1 January 1970.
17-
19+
Returns the number of milliseconds that have elapsed since `00:00:00 Thursday, 1 January 1970`.
20+
1821
## Syntax
19-
22+
2023
```sql
21-
GetCurrentTimestamp ()
22-
```
23-
24+
GetCurrentTimestamp()
25+
```
26+
2427
## Return types
25-
26-
Returns a signed numeric value, the current number of milliseconds that have elapsed since the Unix epoch i.e. the number of milliseconds that have elapsed since 00:00:00 Thursday, 1 January 1970.
2728

28-
## Remarks
29+
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`).
2930

30-
GetCurrentTimestamp() is a nondeterministic function. The result returned is UTC (Coordinated Universal Time).
31+
## Examples
3132

32-
> [!NOTE]
33-
> This system function will not utilize the index. If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
33+
The following example shows how to get the current timestamp.
3434

35-
## Examples
36-
37-
The following example shows how to get the current timestamp using the GetCurrentTimestamp() built-in function.
38-
39-
```sql
40-
SELECT GetCurrentTimestamp() AS currentUtcTimestamp
41-
```
42-
43-
Here is an example result set.
44-
45-
```json
46-
[{
47-
"currentUtcTimestamp": 1556916469065
48-
}]
49-
```
35+
:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/getcurrenttimestamp/query.novalidate.sql" highlight="2":::
36+
37+
:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/getcurrenttimestamp/result.novalidate.json":::
38+
39+
## Remarks
40+
41+
- This function is nondeterministic.
42+
- The result returned is UTC (Coordinated Universal Time).
43+
- This function doesn't use the index.
44+
- If you need to compare values to the current time, obtain the current time before query execution and use that constant string value in the `WHERE` clause.
5045

5146
## Next steps
5247

5348
- [System functions Azure Cosmos DB](system-functions.yml)
54-
- [Introduction to Azure Cosmos DB](../../introduction.md)
49+
- [`GetCurrentTimestampStatic`](getcurrenttimestampstatic.md)

articles/cosmos-db/nosql/query/getcurrenttimestampstatic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ This function returns the same static timestamp for items within the same partit
5454
## See also
5555

5656
- [System functions](system-functions.yml)
57-
- [`GetCurrentTimestamp` (nonstatic)](getcurrenttimestamp.md)
57+
- [`GetCurrentTimestamp`](getcurrenttimestamp.md)

0 commit comments

Comments
 (0)