Dim tempData As Date
'今月末日
nowDate = DateTime.Now
lastMonth = DateAdd("m", 1, DateValue(CStr(Year(nowDate)) & "/" & CStr(Month(nowDate)) & "/1"))
lastMonth = DateAdd("d", -1, lastMonth)
MsgBox lastMonth
'2008/12/5の末日
nowDate = "2008/12/5"
lastMonth = DateAdd("m", 1, DateValue(CStr(Year(nowDate)) & "/" & CStr(Month(nowDate)) & "/1"))
lastMonth = DateAdd("d", -1, lastMonth)
MsgBox lastMonth
|