PowerApps 中的 Date 和 Time 函数Date and Time functions in PowerApps

将日期和时间组件转换为日期/时间值。Converts date and time components to a date/time value.


Date 函数将单个年、月、日的值转换为日期/时间值。The Date function converts individual Year, Month, and Day values to a Date/Time value. 时间部分为午夜。The time portion is midnight.

  • 如果“年”介于 0 到 1899(含)之间,则函数将该值加上 1900,以计算年份。If Year is between 0 and 1899 (inclusive), the function adds that value to 1900 to calculate the year. 70 成为 197070 becomes 1970.
  • 如果“月”小于 1 或大于 12,则结果将从指定年份的第一个月减去或加上该月数。If Month is less than 1 or more than 12, the result subtracts or adds that many months from the beginning of the specified year.
  • 如果“日”大于指定月的天数,函数将从该月的第一天加上该天数,并返回次月对应的日期。If Day is greater than the number of days in the specified month, the function adds that many days to the first day of the month and returns the corresponding date from a subsequent month. 如果“日”小于 1,函数将从指定月份的第一天减去该天数,再加 1。If Day is less than 1, the function subtracts that many days, plus 1, from the first day of the specified month.

Time 函数将单个小时、分钟和秒的值转换为日期/时间值。The Time function converts individual Hour, Minute, and Second values to a Date/Time value. 其结果不与日期相关联。The result has no date associated with it.

有关如何将字符串转换为值的信息,请参阅 DateValueTimeValueDateTimeValue 函数。See the DateValue, TimeValue, and DateTimeValue functions for information about how to convert a string to a value.

有关详细信息,请参阅处理日期和时间Also see working with dates and times for more information.


日期(年、月、日)Date( Year, Month, Day )

  • 年 - 必需。Year - Required. 大于 1899 的数值将被解释为绝对值(1980 被解释为 1980);介于 0 到 1899 之间的数值将被解释为相对于 1900。Numbers greater than 1899 are interpreted as absolute (1980 is interpreted as 1980); numbers that range from 0 to 1899 are interpreted as relative to 1900. (例如,80 将被解释为 1980。)(For example, 80 is interpreted as 1980.)
  • 月 - 必需。Month - Required. 该数值介于 1 到 12 之间。A number that ranges from 1 to 12.
  • 日 - 必需。Day - Required. 该数值介于 1 到 31 之间。A number that ranges from 1 to 31.

时间(小时、分钟、秒)Time( Hour, Minute, Second )

  • 小时 - 必需。Hour - Required. 该数值介于 0(上午 12:00)到 23(下午 11:00)之间。A number that ranges from 0 (12:00 AM) to 23 (11:00 PM).
  • 分钟 - 必需。Minute - Required. 该数值介于 0 到 59 之间。A number that ranges from 0 to 59.
  • 秒 - 必需。Second - Required. 该数值介于 0 到 59 之间。A number that ranges from 0 to 59.



如果用户在“HireYear”文本输入控件中键入“1979”,在“HireMonth”文本输入控件中键入“3”,在“HireDay”文本输入控件中键入“17”,那么此函数会返回“3/17/1979”:If a user typed 1979 in a text-input control named HireYear, 3 in a text-input control named HireMonth, and 17 in a text-input control named HireDay, this function would return 3/17/1979:

Date(Value(HireYear.Text), Value(HireMonth.Text), Value(HireDay.Text))Date(Value(HireYear.Text), Value(HireMonth.Text), Value(HireDay.Text))


如果用户在“BirthHour”文本输入控件中键入“14”,在“BirthMinute”文本输入控件中键入“50”,在“BirthSecond”文本输入控件中键入“24”,那么此函数会返回“02:50:24 p”。If a user typed 14 in a text-input control named BirthHour, 50 in a text-input control named BirthMinute, and 24 in a text-input control named BirthSecond, this function would return 02:50:24 p.

Text(Time(Value(BirthHour.Text), Value(BirthMinute.Text), Value(BirthSecond.Text)), "hh:mm:ss a/p")Text(Time(Value(BirthHour.Text), Value(BirthMinute.Text), Value(BirthSecond.Text)), "hh:mm:ss a/p")