如何使用缩写的月份在 VBA 中格式化日期?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15398759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 15:08:28  来源:igfitidea点击:

How do I format a date in VBA with an abbreviated month?

vbadate

提问by ob213

The code I am using is:

我使用的代码是:

Format(now(), "MMMM dd, yyyy") 

This code returns something like the following:

此代码返回如下内容:

March 10, 2013

2013 年 3 月 10 日

How do I modify the date format code to output the abbreviated month as shown below?

如何修改日期格式代码以输出缩写的月份,如下所示?

Mar 10, 2013

2013 年 3 月 10 日

回答by Iswanto San

Use this:

用这个:

Format(Now, "MMMM dd, yyyy")

More: Format Function

更多:格式化函数

回答by DigCamara

I'm using

我正在使用

Sheet1.Range("E2", "E3000").NumberFormat = "dd/mm/yyyy hh:mm:ss"

to format a column

格式化列

So I guess

所以我猜

Sheet1.Range("E2", "E3000").NumberFormat = "MMM dd yyyy"

would do the trick for you.

会为你做的伎俩。

More: NumberFormat function.

更多:NumberFormat 函数