以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 关于跨年度日期 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=95848) |
-- 作者:zhangxl1964 -- 发布时间:2017/2/7 7:57:00 -- 关于跨年度日期 老师:你好! 1 Dim QueryMonth As Date \'自定义日期 2 Dim FirstDay As Date = New Date(QueryMonth.Year,QueryMonth.Month,1) \'第一天 3 Dim LastDay As Date = New Date(QueryMonth.Year,QueryMonth.Month,Date.DaysInMonth(QueryMonth.Year,QueryMonth.Month)) \'最后一天 4 Dim sFirstDay As Date = New Date(QueryMonth.Year,QueryMonth.Month-1,1) \'上月第一天 5 Dim sLastDay As Date = New Date(QueryMonth.Year,QueryMonth.Month-1,Date.DaysInMonth(QueryMonth.Year,QueryMonth.Month-1)) \'上月最后一天 Dim QueryMonth As Date =\'2016-01-01\'时,执行时4,5 弹出转化错误, 怎样修改成跨年度通用的当前日期的转化为上月的日期?
|
-- 作者:有点蓝 -- 发布时间:2017/2/7 8:59:00 -- Dim QueryMonth As Date = Date.Today \'自定义日期 Dim FirstDay As Date = New Date(QueryMonth.Year,QueryMonth.Month,1) \'第一天 Dim LastDay As Date = New Date(QueryMonth.Year,QueryMonth.Month,Date.DaysInMonth(QueryMonth.Year,QueryMonth.Month)) \'最后一天 Dim sFirstDay As Date = FirstDay.AddMonths(-1) \'上月第一天 Dim sLastDay As Date = FirstDay.AddDays(-1) \'上月最后一天
|
-- 作者:有点色 -- 发布时间:2017/2/7 9:15:00 -- 用相对日期最好
Dim QueryMonth As Date = Date.Today \'自定义日期
Dim FirstDay As Date = New Date(QueryMonth.Year,QueryMonth.Month,1) \'第一天
Dim LastDay As Date = FirstDay.AddMonths(1).AddDays(-1) \'最后一天
Dim sFirstDay As Date = FirstDay.AddMonths(-1) \'上月第一天
Dim sLastDay As Date = FirstDay.AddDays(-1) \'上月最后一天
|