适用范围: NoSQL
返回根据各种日期和时间不见的输入数值构造的日期和时间字符串值。
语法
DateTimeFromParts(<numeric_year>, <numeric_month>, <numeric_day> [, <numeric_hour>]  [, <numeric_minute>]  [, <numeric_second>] [, <numeric_second_fraction>])
参数
| 描述 | |
|---|---|
numeric_year | 
表示年份的正整数值。 此参数采用 ISO 8601 格式 yyyy。 | 
numeric_month | 
表示月份的正整数值。 此参数采用 ISO 8601 格式 mm。 | 
numeric_day | 
表示日期的正整数值。 此参数采用 ISO 8601 格式 dd。 | 
numeric_hour(可选) | 
表示小时的可选正整数值。 此参数采用 ISO 8601 格式 hh。 如果未指定,默认值为 0。 | 
numeric_minute(可选) | 
表示分钟的可选正整数值。 此参数采用 ISO 8601 格式 mm。 如果未指定,默认值为 0。 | 
numeric_second(可选) | 
秒的可选的正整数值。 此参数采用 ISO 8601 格式 ss。 如果未指定,默认值为 0。 | 
numeric_second_fraction(可选) | 
表示秒的小数部分的可选正整数值。 此参数采用 ISO 8601 格式 fffffffZ。 如果未指定,默认值为 0。 | 
返回类型
返回 ISO 8601 格式 YYYY-MM-DDThh:mm:ss.fffffffZ 的 UTC 日期和时间字符串。
示例
以下示例使用了各种参数组合来创建日期和时间字符串。 此示例使用了日期和时间 2017 年 4 月 20 日 13:15 UTC。
SELECT VALUE {
    constructMinArguments: DateTimeFromParts(2017, 4, 20),
    constructMinEquivalent: DateTimeFromParts(2017, 4, 20, 0, 0, 0, 0),
    constructAllArguments: DateTimeFromParts(2017, 4, 20, 13, 15, 20, 3456789),
    constructPartialArguments: DateTimeFromParts(2017, 4, 20, 13, 15),
    constructInvalidArguments: DateTimeFromParts(-2000, -1, -1)
}
[
  {
    "constructMinArguments": "2017-04-20T00:00:00.0000000Z",
    "constructMinEquivalent": "2017-04-20T00:00:00.0000000Z",
    "constructAllArguments": "2017-04-20T13:15:20.3456789Z",
    "constructPartialArguments": "2017-04-20T13:15:00.0000000Z"
  }
]
注解
- 如果指定的整数将创建无效的日期和时间,则该函数将返回 
undefined。