DateTimeToTicks (Azure Cosmos DB)DateTimeToTicks (Azure Cosmos DB)
适用于:
SQL API
将指定的 DateTime 转换为时钟周期。Converts the specified DateTime to ticks. 一个计时周期表示一百纳秒,即一千万分之一秒。A single tick represents one hundred nanoseconds or one ten-millionth of a second.
语法Syntax
DateTimeToTicks (<DateTime>)
参数Arguments
DateTimeDateTime
YYYY-MM-DDThh:mm:ss.fffffffZ
格式的 UTC 日期和时间 ISO 8601 字符串值UTC date and time ISO 8601 string value in the format YYYY-MM-DDThh:mm:ss.fffffffZ
返回类型Return types
返回一个有符号的数值,即自 Unix 时间以来 100 纳秒时钟周期的当前数字。Returns a signed numeric value, the current number of 100-nanosecond ticks that have elapsed since the Unix epoch. 换句话说,DateTimeToTicks 返回自 1970 年 1 月 1 日星期四 00:00:00 以来 100 纳秒时钟周期的数字。In other words, DateTimeToTicks returns the number of 100-nanosecond ticks that have elapsed since 00:00:00 Thursday, 1 January 1970.
备注Remarks
如果 DateTime 不是有效的 ISO 8601 DateTime,则 DateTimeDateTimeToTicks 将返回 undefined
DateTimeDateTimeToTicks will return undefined
if the DateTime is not a valid ISO 8601 DateTime
此系统函数不会使用索引。This system function will not utilize the index.
示例Examples
下面是返回时钟周期的数字的示例:Here's an example that returns the number of ticks:
SELECT DateTimeToTicks("2020-01-02T03:04:05.6789123Z") AS Ticks
[
{
"Ticks": 15779342456789124
}
]
下面的示例返回时钟周期的数字,而不指定秒数的小数部分:Here's an example that returns the number of ticks without specifying the number of fractional seconds:
SELECT DateTimeToTicks("2020-01-02T03:04:05Z") AS Ticks
[
{
"Ticks": 15779342450000000
}
]