There are still confusions in date time formats like DD/MM/YYYY and to MM/DD/YYY. While I was creating an interface between mobile and the Lotus notes, the date time formats confuses me a lot. So I have decided to send the date time as a simple string to mobile.
So, I have written a function which get the NotesDateTime object as a parameter and returns the date string in the DD - MMM - YYYY format. For Eg. 20 - May - 2012.
Function getDateString(
tempDate As NotesDateTime) As String
On Error GoTo errorHandler
Dim dateStr As String
Dim temp As Integer
Dim formula As String
Dim evalResult As Variant
temp = Day(tempDate.DateOnly)
If temp<10 Then
dateStr = "0" + CStr(temp) + "-"
Else
dateStr = CStr(temp) + "-"
End If
temp = Month(tempDate.DateOnly)
formula = |@If(| + Cstr(temp) + |=1;"Jan";| + Cstr(temp) + |=2;"Feb";| + Cstr(temp) + |=3;"Mar";| + Cstr(temp) + |=4;"Apr";| + Cstr(temp) + |=5;"May";| + Cstr(temp) + |=6;"Jun";| + Cstr(temp) + |=7;"Jul";| + Cstr(temp) + |=8;"Aug";| + Cstr(temp) + |=9;"Sep";| + Cstr(temp) + |=10;"Oct";| + Cstr(temp) + |=11;"Nov";| + Cstr(temp) + |=12;"Dec";"")|
evalResult = Evaluate(formula)
dateStr = dateStr + evalResult(0) + "-"
temp = Year(tempDate.DateOnly)
dateStr = dateStr + CStr(temp)
getDateString = dateStr
Exit Function
errorHandler:
MsgBox Error() + " " + CStr(Erl())
Exit Function
End Function
This function helps me to avoid the unwanted confusions and condition checks in backend as well in frontend functionality. I hope this will help you the most.
No comments:
Post a Comment