बहुत बार Programmer को problem होती है की Form पर डाटा तो display String में होने चाहिए और database में डाटा date format में save होने चाहिए इस लिए ये दो function बनाये हे आप अपनी इच्छा अनुसार परिवर्तन करके काम में ले सकते है
Public Function StringCovDate(strDate As String, Optional styDate As Integer = 1) As Date
Dim t() As String
t = Split(strDate, "/")
Select Case styDate
Case 1
StringCovDate = DateSerial(CInt(t(2)), CInt(t(1)), CInt(t(0)))
Case 2
StringCovDate = DateSerial(CInt(t(2)), CInt(t(0)), CInt(t(1)))
Case 3
StringCovDate = DateSerial(CInt(t(0)), CInt(t(2)), CInt(t(3)))
End Select
End Function
Public Function DateCovString(sDate As Date, Optional styDate As Integer = 1) As String
Dim cuDate As String
Select Case styDate
Case 1
cuDate = Format(sDate, "dd/MM/yyyy")
Case 2
cuDate = Format(sDate, "MM/dd/yyyy")
Case 3
cuDate = Format(sDate, "yyyy/MM/dd")
End Select
DateCovString = cuDate
End Function
Public Function StringCovDate(strDate As String, Optional styDate As Integer = 1) As Date
Dim t() As String
t = Split(strDate, "/")
Select Case styDate
Case 1
StringCovDate = DateSerial(CInt(t(2)), CInt(t(1)), CInt(t(0)))
Case 2
StringCovDate = DateSerial(CInt(t(2)), CInt(t(0)), CInt(t(1)))
Case 3
StringCovDate = DateSerial(CInt(t(0)), CInt(t(2)), CInt(t(3)))
End Select
End Function
Public Function DateCovString(sDate As Date, Optional styDate As Integer = 1) As String
Dim cuDate As String
Select Case styDate
Case 1
cuDate = Format(sDate, "dd/MM/yyyy")
Case 2
cuDate = Format(sDate, "MM/dd/yyyy")
Case 3
cuDate = Format(sDate, "yyyy/MM/dd")
End Select
DateCovString = cuDate
End Function