CSDN博客

img xuandhu

我的工作日志

发表于2004/10/8 10:44:00  639人阅读

分类: 其它

没有系统对日期补0,只有手动补0

'针对LEADBBS数据库的,来源BOARD_POPFUN.ASP 作用:日期处理
'例子:GetTimeValue(NOW())
'结果:20041008095752

Function GetTimeValue(DateString)
 Dim Temp,TempStr
 If isNull(DateString) or isTrueDate(DateString) = 0  Then Exit Function
 Temp = csTr(Year(DateString))
 If len(temp)<3 Then
  Temp = left(year(date),2) & temp
 End If
 TempStr = Temp
 
 Temp = csTr(month(DateString))
 If len(temp)<2 Then Temp = "0" & temp
 TempStr = TempStr & Temp

 Temp = csTr(day(DateString))
 If len(temp)<2 Then Temp = "0" & temp
 TempStr = TempStr & Temp

 Temp = csTr(Hour(DateString))
 If len(temp)<2 Then Temp = "0" & temp
 TempStr = TempStr & Temp

 Temp = csTr(Minute(DateString))
 If len(temp)<2 Then Temp = "0" & temp
 TempStr = TempStr & Temp

 Temp = csTr(Second(DateString))
 If len(temp)<2 Then Temp = "0" & temp
 TempStr = TempStr & Temp

 GetTimeValue = cCur(TempStr)
End Function
Rem 为VBScript的isDate缺陷而编写的函数,用on error resume next也拦不住
Function isTrueDate(TStr)
 Dim T
 T = TStr
 T = Replace(Replace(Replace(Replace(Replace(Replace(Replace(T,"年","-"),"月","-"),"日"," "),"上午"," "),"下午"," "),"  "," "),"  "," ")
 
 Dim N1,N2
 N1 = inStr(T,"-")
 If N1>0 Then N2 = inStrRev(T,"-")
 If N1 = N2 and N1 >0 Then
  isTrueDate = 0
  Exit Function
 End If

 N1 = inStr(T,":")
 If N1>0 Then N2 = inStrRev(T,"-")
 If N1 = N2 and N1 >0 Then
  isTrueDate = 0
  Exit Function
 End If

 If isDate(TStr) Then
  isTrueDate = 1
 Else
  isTrueDate = 0
 End If
End Function

阅读全文
0 0

相关文章推荐

img
取 消
img