madelca100
MIS
I have the following situation:
Access 97 linked via ODBC to Oracle db (not sure of version - don't think it matters).
Dates are stored as character in format "yyyymmdd" (not my design).
I wrote my first Access function as follows
Function convertYYYYMMDD2Date(strDateField As String) As Date
If IsNull(strDateField) Or Not IsNumeric(strDateField) Then
Exit Function
Else
convertYYYYMMDD2Date = DateValue(Mid(strDateField, 5, 2) & "/" & Mid(strDateField, 7, 2) & "/" & Mid(strDateField, 1, 4))
End If
End Function
This does convert dates properly
(e.g., 20010625 converts to 6/25/2001)
However it converts nulls to #Error.
I was hoping to trap the nulls with the first line of code. (Based on searches to this forum.)
I've also tried assigning Null (convertYYYYMMDD2Date = Null) with the same effect.
How do I make the date null when the input is also null?
thanks,
mike
Access 97 linked via ODBC to Oracle db (not sure of version - don't think it matters).
Dates are stored as character in format "yyyymmdd" (not my design).
I wrote my first Access function as follows
Function convertYYYYMMDD2Date(strDateField As String) As Date
If IsNull(strDateField) Or Not IsNumeric(strDateField) Then
Exit Function
Else
convertYYYYMMDD2Date = DateValue(Mid(strDateField, 5, 2) & "/" & Mid(strDateField, 7, 2) & "/" & Mid(strDateField, 1, 4))
End If
End Function
This does convert dates properly
(e.g., 20010625 converts to 6/25/2001)
However it converts nulls to #Error.
I was hoping to trap the nulls with the first line of code. (Based on searches to this forum.)
I've also tried assigning Null (convertYYYYMMDD2Date = Null) with the same effect.
How do I make the date null when the input is also null?
thanks,
mike