Reputation: 768
i written a code in vb for finding the last month. but i didn't get the output which i am expecting. here is my code:
a=Format$(Now, "mm")-1
but i want output in 2 digit like if last month is Jan then output should be 01 not only 1
please help me out.
Upvotes: 4
Views: 11761
Reputation: 5815
Use the DateAdd function. More specifically:
date d = DateAdd("m", -1, Now)
a = Format(d, "mm")
Upvotes: 11