【问题标题】:Print date in Month name day, year format以月名日、年格式打印日期
【发布时间】:2014-11-29 04:11:56
【问题描述】:

我希望以月名日、年格式打印当前日期(例如:2014 年 10 月 3 日)。我知道我可以使用 Month(Date)Month(Now) 以整数格式获取当前月份,但我想知道如何以文本格式输出当前月份。

【问题讨论】:

    标签: vba date ms-word


    【解决方案1】:

    在等待没人回答这个问题时,我发现您可以使用MonthName( number, [ abbreviate ] ) 函数来打印月份名称。从我的例子可以看出,这个函数的参数是数字,它是一个从 1 到 12 的值,代表月份,以及 abbreviate,它是一个可选的布尔值。如果此参数设置为 TRUE,则表示月份名称将被缩写。如果此参数设置为 FALSE 或省略,则月份名称不会缩写;现在让我们回过头来回答这个问题。

    由于Month(Date)返回的是月份的数字,所以可以将其设置为MonthName(); soMonthName(Month(Date))will return the name of the current month. You can then print the current date in the Month name day, year format with this code:MonthName(Month(Date))&""&Day(Date)的第一个参数) & ", " & 年份(日期)`。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-29
      • 1970-01-01
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多