【译文】在查询里以当前月份为条件-周芳
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> Access数据库-查询/SQL语句


【译文】在查询里以当前月份为条件

发表时间:2012/4/23 8:47:28 评论(4) 浏览(8951)  评论 | 加入收藏 | 复制
   
摘 要:创建一个查询返回当月的所有日期的记录
正 文:

原作者:Juan Soto 翻译:周芳

【译文】在查询里以当前月份为条件

        那天,我需要创建一个查询返回当月的所有日期的记录。我不想编程使用开始日期和结束日期来查询,所以我想出了下面代码行,你可以直接粘贴到你的查询代码中:

Between CDate(Month(Date()) &  “/1/”  & Year(Date())) And DateAdd(“m”,1,CDate(Month(Date()) & “/1/” & Year(Date())))-1

        以上使用“Between And”的标准是计算当前日期的月初和月底。希望大家受用!

 

【原文】Criteria for the current month in a query
The other day I needed to create a query where it returns all records with dates for the current month. I did not want to hard code the beginning and ending dates in the query, so I came up with the following line of code you can paste into your query:
Between CDate(Month(Date()) & “/1/” & Year(Date())) And DateAdd(“m”,1,CDate(Month(Date()) & “/1/” & Year(Date())))-1
The criteria line above uses the “Between And” operators to calculate the first of the month and the end of the month of the current date. Enjoy!


Access软件网交流QQ群(群号:198465573)
 
 相关文章
显示当前月份示例\=Month(Date())\Month函数用法...  【麥田  2010/2/3】
Access查询 交流QQ群群号:54525238 欢迎学习acc...  【宏鹏  2012/10/26】
常见问答
技术分类
相关资源
文章搜索
关于作者

周芳

文章分类

文章存档

友情链接