Dim MyDate
MyDate = Date
For i = 0 To 4 Step 1
Strformatdate = FormatDateTime(MyDate, i)
If i = 0 Then
MsgBox "General Date Is:" & Strformatdate
ElseIf i = 1 Then
MsgBox "Long Date Is:" & Strformatdate
ElseIf i = 2 Then
MsgBox "Short Date Is:" & Strformatdate
ElseIf i = 3 Then
MsgBox "Long time Is:" & Strformatdate
Else
MsgBox "Short time Is:" & Strformatdate
End If
Next
Tuesday, May 25, 2010
Date value function
Dim MyDate, StrDatevalue
MyDate = "1,14,1980"
StrDatevalue = DateValue(MyDate)
MsgBox StrDatevalue
MyDate = "1,14,1980"
StrDatevalue = DateValue(MyDate)
MsgBox StrDatevalue
Date Serial function
Dim StrDateserial
StrDateserial = DateSerial(1981 + 1 - 2, 11 - 1, 11 - 1)
MsgBox StrDateserial
StrDateserial = DateSerial(1981 + 1 - 2, 11 - 1, 11 - 1)
MsgBox StrDateserial
Date Part Function
Dim MyDate, MySysDate
MyDate = "January 11, 1981"
MyReturn = CDate(MyDate)
MsgBox MyReturn
StrDatepart = DatePart("yyyy", MyDate)
MsgBox StrDatepart
MyDate = "January 11, 1981"
MyReturn = CDate(MyDate)
MsgBox MyReturn
StrDatepart = DatePart("yyyy", MyDate)
MsgBox StrDatepart
Compare the Two Date
Dim MyDate, MySysDate
MySysDate = Date
MsgBox MySysDate
MyDate = "January 11, 1981"
MyReturn = CDate(MyDate)
MsgBox MyReturn
StrDateCompare = DateDiff("yyyy", MyReturn, MySysDate)
MsgBox StrDateCompare
MySysDate = Date
MsgBox MySysDate
MyDate = "January 11, 1981"
MyReturn = CDate(MyDate)
MsgBox MyReturn
StrDateCompare = DateDiff("yyyy", MyReturn, MySysDate)
MsgBox StrDateCompare
Subscribe to:
Posts (Atom)