But I run into trouble thinking of a way to get a 12 and 11 returned to me when January is the first month, or 01 and 12 for February, for example.
You can use DateAdd to get what you want. Here is an example
Option Explicit
Sub Sample()
Dim dt As Date
Dim PrevMonth As String
Dim MonthPrevToPrevMonth As String
dt = Now
PrevMonth = Format(DateAdd("M", -1, dt), "M")
MonthPrevToPrevMonth = Format(DateAdd("M", -2, dt), "M")
Debug.Print PrevMonth
Debug.Print MonthPrevToPrevMonth
End Sub
Here is a test with Jan
and Feb
dates.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…