设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

月初,月末,本月天数的函数

1970-1-1 08:00| 发布者: huanghai『文章』| 查看: 2318| 评论: 0

'? 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


最新评论

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

GMT+8, 2025-4-4 05:15 , Processed in 0.090052 second(s), 16 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部