|
一天有多少天的函數。
Public Function my_daily(nowdate As Date) As Integer
Dim my_date_first_day As Date '定義當前月的第一天
Dim my_date_last_day As Date '定義當下個月的第一天
Dim my_date_current_day As Integer '定義今天為當前月的第几天
my_date_current_day = Day(nowdate)
my_date_first_day = DateAdd("d", -(my_date_current_day - 1), nowdate)
my_date_last_day = DateAdd("m", 1, my_date_first_day)
my_daily = DateDiff("d", my_date_first_day, my_date_last_day)
End Function
-------------------------------------------------------------
如:my_daily("2002-2-1") 返回28
my_daily("2002-7-1") 返回31
[em04][em06][em06][em04] |
|