如何更改格式化日期的语言环境? [英] How to change the locale of a formatted date?
本文介绍了如何更改格式化日期的语言环境?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以英语月份名称的特定格式检索今天的日期.
I want to retrieve today's date in a specific format with English month name.
我正在使用
Format(DateValue(Now), "dd-mmm-yyyy")
,
这给了我
05-cze-2013
,
这是波兰语.我想要得到的是
05-Jan-2013
.
I'm using
Format(DateValue(Now), "dd-mmm-yyyy")
,
which gives me
05-cze-2013
,
which is in Polish. What I want to get is
05-Jan-2013
.
我只对VBA解决方案感兴趣.还请提供一种使用VBA将语言环境设置回原始语言环境的方法.
I am only interested in a VBA solution. Please also provide a way to set the locale back to the original, also using VBA.
推荐答案
这不是很难...
Sub VBA_Dates_Format()
Cells.Clear
Range("A1").Value = Now
Range("A2").Value = Now
' Polish
Range("A1").NumberFormat = "[$-415]d mmm yy;@"
' English UK
Range("A2").NumberFormat = "[$-809]d mmm yy;@"
End Sub
我已经通过记录和修改宏以使其符合标准来实现了这一目标.
可在此处进一步阅读
I have achieved this by recording and modifying a macro to fit the criteria.
Further reading available here
这篇关于如何更改格式化日期的语言环境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文