gpt4 book ai didi

java - 如何将日期时间字段保存到cosmosdb "SQL API/DocumentDb"?

转载 作者:行者123 更新时间:2023-12-03 04:13:03 26 4
gpt4 key购买 nike

我将 DateTime 字段从 Java 发送到 documentdb/SQL API 到 cosmos db 。但它将日期时间保存为 documentdb 中的数字,如果我将日期时间值解析为字符串,则 documentdb 将以字符串形式正确显示,但我需要在 documentdb/SQL API 中以日期时间格式显示它。

在 documentdb 中保存日期时间值而不将其解析为字符串的最佳实践是什么?如果我不将日期时间字段解析为字符串,documentdb 集合中日期字段的值是多少?例如 "loggedAt": 1554207604392 在 documentdb 中显示此数字。谁能帮我解决这个问题。

Document Db Item, highlighted field is the datetime which i am sending from java

最佳答案

What is the value of the date field in the documentdb collection if i not parse my datetime field to string ?

该数字代表自 1970 年 1 月 1 日以来经过的秒数,它与 Unix 时间戳 的数据时间相匹配。 Azure Cosmos DB 的内部时间戳 (_ts) 属性遵循此方法。你可以引用这个document了解详情。

enter image description here

What's the best practise to save datetime value in documentdb without parsing it to string?

来自此反馈 case ,ms不支持原生datetime类型数据。在此blog ,日期时间数据仍然被视为字符串或数字。

对于unix时间戳查询操作,可以按照我之前的案例:Convert TimeScript to Date in Azure CosmosDB SQL Query使用 UDF 将 unix 时间戳转换为日期时间。或者从这个案例中得到一些线索:Date Between Query in Cosmos DB

关于java - 如何将日期时间字段保存到cosmosdb "SQL API/DocumentDb"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55474865/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com