DateTimePart (Azure Cosmos DB)DateTimePart (Azure Cosmos DB)
适用于:
SQL API
返回指定 DateTime 之间指定 DateTimePart 的值。Returns the value of the specified DateTimePart between the specified DateTime.
语法Syntax
DateTimePart (<DateTimePart> , <DateTime>)
参数Arguments
DateTimePartDateTimePart
DateTimePart 将为其返回值的日期部分。The part of the date for which DateTimePart will return the value. 此表列出了所有有效的 DateTimePart 参数:This table lists all valid DateTimePart arguments:
DateTimePartDateTimePart | 缩写abbreviations |
---|---|
YearYear | "year", "yyyy", "yy""year", "yyyy", "yy" |
MonthMonth | "month", "mm", "m""month", "mm", "m" |
日期Day | "day", "dd", "d""day", "dd", "d" |
HourHour | "hour", "hh""hour", "hh" |
MinuteMinute | "minute", "mi", "n""minute", "mi", "n" |
秒Second | "second", "ss", "s""second", "ss", "s" |
MillisecondMillisecond | "millisecond", "ms""millisecond", "ms" |
MicrosecondMicrosecond | "microsecond", "mcs""microsecond", "mcs" |
NanosecondNanosecond | "nanosecond", "ns""nanosecond", "ns" |
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
返回正整数值。Returns a positive integer value.
备注Remarks
由于以下原因,DateTimePart 返回 undefined
:DateTimePart will return undefined
for the following reasons:
- 指定的 DateTimePart 值无效The DateTimePart value specified is invalid
- DateTime 不是有效的 ISO 8601 DateTimeThe DateTime is not a valid ISO 8601 DateTime
此系统函数不会使用索引。This system function will not utilize the index.
示例Examples
下面是返回月份整数值的示例:Here's an example that returns the integer value of the month:
SELECT DateTimePart("m", "2020-01-02T03:04:05.6789123Z") AS MonthValue
[
{
"MonthValue": 1
}
]
下面是返回微秒数的示例:Here's an example that returns the number of microseconds:
SELECT DateTimePart("mcs", "2020-01-02T03:04:05.6789123Z") AS MicrosecondsValue
[
{
"MicrosecondsValue": 678912
}
]