Office中国论坛/Access中国论坛

标题: 怎样设置日期的默认值为:每月第一天 [打印本页]

作者: dz983110    时间: 2011-5-21 16:28
标题: 怎样设置日期的默认值为:每月第一天
如题.
作者: hjb016    时间: 2011-5-21 16:35
format(date,"YYYY/MM") & "/01"
作者: VulcanTerry    时间: 2011-5-21 16:55
DateSerial(Year(Date()),Month(Date()),1)
作者: dz983110    时间: 2011-5-21 20:40
谢谢,
作者: liaohk    时间: 2011-5-21 20:53
得到一个日期当月第一天,最后一天是星期几
正 文:


得到一个日期当月第一天是星期几
Function getYMweekday(sDate As Date) As String

Dim intY As Integer
Dim intM As Integer

intY = Year(sDate)
intM = Month(sDate)
getYMweekday = WeekdayName(Weekday(DateSerial(intY, intM, 1)))

End Function

得到一个日期当月最后一天是星期几

Function getYMweekdayEnd(sDate As Date) As String

Dim intY As Integer
Dim intM As Integer

intY = Year(sDate)
intM = Month(sDate)
getYMweekdayEnd = WeekdayName(Weekday(DateSerial(intY, intM + 1, 0)))

End Function


Sub aa()
Debug.Print getYMweekday(Date)
Debug.Print getYMweekdayEnd(Date) 'date为2007-12-3
End Sub






欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3