H
hazel4832
I currently have a table in MS Access, which is an import from another
program. It has the column 'Date of Confirmed Corrective Action
Closure', which goes in as text. The dates in this field are formatted
as 'MMM-DD-YYYY', with MMM being the first 3 letters of the month. I
an trying to basically convert this into a date. I have an ALTER query
that adds the column Closed Date to the Table and sets it as type Date/
Time. I have created a function that converts the MMM into a number.
Public Function StrToMonth(strIn As String) As Integer
Dim arrMonth(12) As Variant
Dim i As Integer
arrMonth(0) = "JAN"
arrMonth(1) = "FEB"
arrMonth(2) = "MAR"
arrMonth(3) = "APR"
arrMonth(4) = "MAY"
arrMonth(5) = "JUN"
arrMonth(6) = "JUL"
arrMonth(7) = "AUG"
arrMonth(8) = "SEP"
arrMonth(9) = "OCT"
arrMonth(10) = "NOV"
arrMonth(11) = "DEC"
For i = 0 To UBound(arrMonth) - 1
If strIn = arrMonth(i) Then
StrToMonth = i + 1
Exit Function
End If
Next i
End Function
I am trying to create and UPDATE query that calls this function in
order to get the Month number.
UPDATE Environmental SET Environmental.ClosedDate = DateSerial(Val(Mid
([Date of Confirmed Corrective Action Closure],8,4)),monthname,Val(Mid
([Date of Confirmed Corrective Action Closure],5,2)));
I also have monthname:StrToMonth('Date of Confirmed Corrective Action
Closure')
I am getting errors. It doesn't even look as itf it is getting tot he
function part of the query.
Could anyone assist me with this?
Thanks.
program. It has the column 'Date of Confirmed Corrective Action
Closure', which goes in as text. The dates in this field are formatted
as 'MMM-DD-YYYY', with MMM being the first 3 letters of the month. I
an trying to basically convert this into a date. I have an ALTER query
that adds the column Closed Date to the Table and sets it as type Date/
Time. I have created a function that converts the MMM into a number.
Public Function StrToMonth(strIn As String) As Integer
Dim arrMonth(12) As Variant
Dim i As Integer
arrMonth(0) = "JAN"
arrMonth(1) = "FEB"
arrMonth(2) = "MAR"
arrMonth(3) = "APR"
arrMonth(4) = "MAY"
arrMonth(5) = "JUN"
arrMonth(6) = "JUL"
arrMonth(7) = "AUG"
arrMonth(8) = "SEP"
arrMonth(9) = "OCT"
arrMonth(10) = "NOV"
arrMonth(11) = "DEC"
For i = 0 To UBound(arrMonth) - 1
If strIn = arrMonth(i) Then
StrToMonth = i + 1
Exit Function
End If
Next i
End Function
I am trying to create and UPDATE query that calls this function in
order to get the Month number.
UPDATE Environmental SET Environmental.ClosedDate = DateSerial(Val(Mid
([Date of Confirmed Corrective Action Closure],8,4)),monthname,Val(Mid
([Date of Confirmed Corrective Action Closure],5,2)));
I also have monthname:StrToMonth('Date of Confirmed Corrective Action
Closure')
I am getting errors. It doesn't even look as itf it is getting tot he
function part of the query.
Could anyone assist me with this?
Thanks.