设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
查看: 2314|回复: 5

[模块/函数] [源码] 月初,月末,本月天数的函数

[复制链接]
发表于 2003-9-30 17:59:00 | 显示全部楼层 |阅读模式
'? firstDayOfMonth("2003-2-4")
'  2003-2-1

'? lastDayOfMonth("2003-2-4")
'  2003-2-28

'? DaysInMonth("2003-2-4")
'  28

Function firstDayOfMonth(myDate As Date) As Date
    firstDayOfMonth = CDate(Format(myDate, "yyyy-m-1"))
End Function

Function lastDayOfMonth(myDate As Date) As Date
    lastDayOfMonth = DateAdd("d", -1, DateAdd("M", 1, firstDayOfMonth(myDate)))
End Function

Function DaysInMonth(myDate As Date) As Integer
    DaysInMonth = DateDiff("d", firstDayOfMonth(myDate), lastDayOfMonth(myDate)) + 1
End Function
发表于 2003-9-30 18:33:00 | 显示全部楼层
谢谢黄大师为我们送来简洁实用的源代码!
发表于 2003-10-1 01:38:00 | 显示全部楼层

[源码] 月初,月末,本月天数的函数

终于找到了,

建议版主把这种实用的贴子放到精华贴里,这样更方便
发表于 2008-9-2 12:44:43 | 显示全部楼层
支持啊
发表于 2008-9-2 14:45:48 | 显示全部楼层
支持啊
发表于 2009-11-7 10:44:29 | 显示全部楼层
支持收藏了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2024-3-28 19:56 , Processed in 0.088823 second(s), 30 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表