Skip to content

Commit f5360b3

Browse files
committed
update datetime doc precision recommend
1 parent 84aa8e1 commit f5360b3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

articles/cosmos-db/working-with-dates.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.service: cosmos-db
55
author: SnehaGunda
66
ms.author: sngun
77
ms.topic: conceptual
8-
ms.date: 03/03/2020
8+
ms.date: 04/03/2020
99
---
1010
# Working with Dates in Azure Cosmos DB
1111

@@ -15,7 +15,9 @@ In addition to the basic types, many applications need the DateTime type to repr
1515

1616
## Storing DateTimes
1717

18-
Azure Cosmos DB supports JSON types such as - string, number, boolean, null, array, object. It does not directly support a DateTime type. Currently, Azure Cosmos DB doesn't support localization of dates. So, you need to store DateTimes as strings. The recommended format for DateTime strings in Azure Cosmos DB is `YYYY-MM-DDThh:mm:ss.sssZ` which follows the ISO 8601 UTC standard. It is recommended to store all dates in Azure Cosmos DB as UTC. Converting the date strings to this format will allow sorting dates lexicographically. If non-UTC dates are stored, the logic must be handled at the client-side. To convert a local DateTime to UTC, the offset must be known/stored as a property in the JSON and the client can use the offset to compute UTC DateTime value.
18+
Azure Cosmos DB supports JSON types such as - string, number, boolean, null, array, object. It does not directly support a DateTime type. Currently, Azure Cosmos DB doesn't support localization of dates. So, you need to store DateTimes as strings. The recommended format for DateTime strings in Azure Cosmos DB is `YYYY-MM-DDThh:mm:ss.fffffffZ` which follows the ISO 8601 UTC standard. It is recommended to store all dates in Azure Cosmos DB as UTC. Converting the date strings to this format will allow sorting dates lexicographically. If non-UTC dates are stored, the logic must be handled at the client-side. To convert a local DateTime to UTC, the offset must be known/stored as a property in the JSON and the client can use the offset to compute the UTC DateTime value.
19+
20+
Range queries with DateTime strings as filters are only supported if the DateTime strings are all in UTC and the same length. In Azure Cosmos DB, the [GetCurrentDateTime](sql-query-getcurrentdatetime.md) system function will return the current UTC date and time ISO 8601 string value in the format: `YYYY-MM-DDThh:mm:ss.fffffffZ`.
1921

2022
Most applications can use the default string representation for DateTime for the following reasons:
2123

@@ -41,7 +43,7 @@ For example, the following snippet stores an `Order` object containing two DateT
4143
{
4244
Id = "09152014101",
4345
OrderDate = DateTime.UtcNow.AddDays(-30),
44-
ShipDate = DateTime.UtcNow.AddDays(-14),
46+
ShipDate = DateTime.UtcNow.AddDays(-14),
4547
Total = 113.39
4648
});
4749
```
@@ -70,7 +72,7 @@ The SQL .NET SDK automatically supports querying data stored in Azure Cosmos DB
7072
Translated to the following SQL statement and executed on Azure Cosmos DB:
7173

7274
```sql
73-
SELECT * FROM root WHERE (root["ShipDate"] >= "2016-12-18T21:55:03.45569Z")
75+
SELECT * FROM root WHERE (root["ShipDate"] >= "2014-09-30T23:14:25.7251173Z")
7476
```
7577

7678
You can learn more about Azure Cosmos DB's SQL query language and the LINQ provider at [Querying Cosmos DB in LINQ](sql-query-linq-to-sql.md).

0 commit comments

Comments
 (0)