Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > 源码示例

日期起止值全方位计算

时 间:2009-03-01 21:41:16
作 者:沈军   ID:2469  城市:东莞
摘 要:这里总结了一下师傅们知识,有时候需要在某查询中提高日期范围选择速度,应该对日常工作有所帮助.
正 文:

'1;今年;2;这个月;3;上个月;4;去年;5;所有;6;今年上半年;7;今年下半年;8;今年一季度;9;今年二季度;10;今年三季度;11;今年四季度;12;去年一季度;13;去年二季度;14;去年三季度;15;去年四季度
    Select Case Me.Combo10
    Case 1
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
    Case 2
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), Month(Now()), 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), Month(Now()) + 1, 0)"
    Case 3
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), Month(Now())-1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), Month(Now()), 0)"
    Case 4
        Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())-0, 1, 0)"
    Case 5
        Me.开始日期.ControlSource = "=DMIN('日期','明细帐务资料')"
        Me.结束日期.ControlSource = "=DMAX('日期','明细帐务资料')"
    Case 6
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 7, 0)"
    Case 7
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 7, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
    Case 8
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 4, 0)"
    Case 9
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 4, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 7, 0)"
    Case 10
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 7, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 10, 0)"
    Case 11
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 10, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
'12;去年一季度;13;去年二季度;14;去年三季度;15;去年四季度;16;去年上半年;17;去年下半年;
    Case 12
        Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 4, 0)"
    Case 13
        Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 4, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 0)"
    Case 14
        Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 10, 0)"
    Case 15
        Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 10, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 1, 0)"
    Case 16
        Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 0)"
    Case 17
        Me.开始日期.ControlSource = "=DateSerial(Year(Now())-1, 7, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 1, 0)"
'20;今年1月份;21;今年2月份;22;今年3月份;23;今年4月份;24;今年5月份;25;今年6月份;26;今年7月份;27;今年8月份;28;今年9月份;29;今年10月份;30;今年11月份;31;今年12月份;
    Case 20
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 1, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 2, 0)"
    Case 21
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 2, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 3, 0)"
    Case 22
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 3, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 4, 0)"
    Case 23
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 4, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 5, 0)"
    Case 24
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 5, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 6, 0)"
    Case 25
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 6, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 7, 0)"
    Case 26
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 7, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 8, 0)"
    Case 27
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 8, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 9, 0)"
    Case 28
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 9, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 10, 0)"
    Case 29
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 10, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 11, 0)"
    Case 30
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 11, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now()), 12, 0)"
    Case 31
        Me.开始日期.ControlSource = "=DateSerial(Year(Now()), 12, 1)"
        Me.结束日期.ControlSource = "=DateSerial(Year(Now())+1, 1, 0)"
    End Select



Access软件网官方交流QQ群 (群号:54525238)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助