7,763
社区成员
发帖
与我相关
我的任务
分享
Public V04001 As Integer '年
Public V04002 As Integer '月
Public V04003 As Integer '日
Dim v04001 As Integer, v04002 As Integer, v04003 As Integer
Dim dt As Date
v04001 = 2009: v04002 = 3: v04003 = 0
dt = DateSerial(v04001, v04002, v04003)
v04001 = Year(dt)
v04002 = Month(dt)
v04003 = Day(dt)
Debug.Print v04001; v04002; v04003
'msgbox dateserial(v04001,v04002,v04003)
msgbox dateserial(2010,1,0)
'用dateadd函数来实现(当前月的第一天减去一天则上月的最后一天)
dim tmp as string
dim tmpDate as date
if v04003=0 then
tmp=str(v04001) & "-" & str(v04002) & "-01"
tmpDate=dateadd(d,-1,cdate(tmp))
v04001=year(tmpDate)
v04002=month(tmpDate)
v04003=day(tmpDate)
end if