如何使用 format() 或在 vb 脚本中以任何可能的方式获取上个月的名称和年份?
例如:如果当前月份 = 2 月,我想要输出 = 2014 年 1 月如果当前月份 = 2014 年 1 月,我想要输出 = 2013 年 12 月
请帮忙。
之前的所有答案都是针对 VB.NET 的。如果你想要一个 VBScript 解决方案,试试这个:
' Here's how you can get the starting and ending days of the previous month...
dtEnding = Date - Day(Date)
dtStarting = dtEnding - Day(dtEnding) + 1
' To display the month and year...
MsgBox MonthName(Month(dtEnding)) & " " & Year(dtEnding)
Run Code Online (Sandbox Code Playgroud)