Function ConvertDate(ByVal sDate, ByVal sFormat)
Dim d,m,y,NewDate
d=Day(sDate)
m=Month(sDate)
y=Year(sDate)
If Len(d)=1 Then d = "0" & d
If Len(m)=1 Then m = "0" & m
Select Case sFormat
Case "DD-MM-YYYY"
NewDate = d & "-" & m & "-" & y
Case "DD/MM/YYYY"
NewDate = d & "/" & m & "/" & y
Case "MM/DD/YYYY"
NewDate = m & "/" & d & "/" & y
Case "DD-MON-YYYY"
Select Case CInt(m)
Case "1" mm = "Jan"
Case "2" mm = "Feb"
Case "3" mm = "Mar"
Case "4" mm = "Apr"
Case "5" mm = "May"
Case "6" mm = "Jun"
Case "7" mm = "Jul"
Case "8" mm = "Aug"
Case "9" mm = "Sep"
Case "10" mm = "Oct"
Case "11" mm = "Nov"
Case "12" mm = "Dec"
End Select
NewDate = d & "-" & mm & "-" & y
End Select
ConvertDate = NewDate
End Function
Dim d,m,y,NewDate
d=Day(sDate)
m=Month(sDate)
y=Year(sDate)
If Len(d)=1 Then d = "0" & d
If Len(m)=1 Then m = "0" & m
Select Case sFormat
Case "DD-MM-YYYY"
NewDate = d & "-" & m & "-" & y
Case "DD/MM/YYYY"
NewDate = d & "/" & m & "/" & y
Case "MM/DD/YYYY"
NewDate = m & "/" & d & "/" & y
Case "DD-MON-YYYY"
Select Case CInt(m)
Case "1" mm = "Jan"
Case "2" mm = "Feb"
Case "3" mm = "Mar"
Case "4" mm = "Apr"
Case "5" mm = "May"
Case "6" mm = "Jun"
Case "7" mm = "Jul"
Case "8" mm = "Aug"
Case "9" mm = "Sep"
Case "10" mm = "Oct"
Case "11" mm = "Nov"
Case "12" mm = "Dec"
End Select
NewDate = d & "-" & mm & "-" & y
End Select
ConvertDate = NewDate
End Function
No comments:
Post a Comment