Date.ToText

语法

Date.ToText(date as nullable date, optional options as any, optional culture as nullable text) as nullable text

关于

返回 date 的文本化表示形式。 可以提供可选 record 参数 options 来指定额外的属性。 culture 仅用于旧工作流(请参阅下文)。 record 可以包含以下字段:

  • Format:一个 text 值,指示要使用的格式。 转到 https://go.microsoft.com/fwlink/?linkid=2180104https://go.microsoft.com/fwlink/?linkid=2180105

    省略此字段或提供 null 将导致使用由 Culture 定义的默认值设置日期的格式。

  • Culture:如果 Format 不为 null,则 Culture 会控制某些格式说明符。 例如,在使用 "en-US" 时,"MMM""Jan", "Feb", "Mar", ...,而在使用 "ru-RU" 时,"MMM""янв", "фев", "мар", ...。 当 Formatnull 时,Culture 控制要使用的默认格式。 当 Culturenull 或被省略时,将使用 Culture.Current

若要支持旧工作流,optionsculture 也可以是文本值。 这与 options = [Format = options, Culture = culture] 具有相同的行为。

示例 1

#date(2010, 12, 31) 转换为 text 值。 结果输出可能因当前区域性而异。

使用情况

Date.ToText(#date(2010, 12, 31))

输出

"12/31/2010"

示例 2

使用自定义格式和德语区域性进行转换。

使用情况

Date.ToText(#date(2010, 12, 31), [Format="dd MMM yyyy", Culture="de-DE"])

输出

"31 Dez 2010"

示例 3

在回历中查找与公历中的 2000 年 1 月 1 日相对应的年份。

使用情况

Date.ToText(#date(2000, 1, 1), [Format="yyyy", Culture="ar-SA"])

输出

"1420"

results matching ""

    No results matching ""