weekday用法

来源:百度知道 编辑:UC知道 时间:2024/05/18 09:46:40
asp中:
我想用nian=2008
yue=4
ri=5
我可以用weekday(#2008-4-5#)求出表示星期几的数,而用weekday(#nian-yue-ri#)确不行呢?
请帮助一下。谢谢

(#nian-yue-ri#)不是正确的格式
可以试下转换
(nian*365+yue*31+ri) (这个或许不对,我N久没用VB)

nian = 2008
yue = 4
ri = 5
MsgBox Weekday(DateSerial(nian, yue, ri))

也可利用格式化函数:<自定义的格式化函数>
Public Function FormatTime(ByVal strTime As String, ByVal strType As String)
'formattime代码:
'*参数说明: strtime(string) 要格式化时间变量
' strtype(string) 要格式化形定义
Dim strTemp
strTemp = ""
If Mid(strType, 1, 1) = "1" Then
'返回日期
strTemp = strTemp & Year(strTime) & IIf(Mid(strType, 4, 1) = "1", "年", "-")
strTemp = strTemp & Month(strTime) & IIf(Mid(strType, 4, 1) = "1", "月", "-")
strTemp = strTemp & Day(strTime) & IIf(Mid(strType, 4, 1) = "1", "日", "")
End If
If Mid(strType, 2, 1) = "1" Then
'增加星期
Select Case Weekday(strTime)
Case vbSunda