You have to create a new field on the table for now call it TempDateField with Type Date/Time and then save the table. Create an UPDATE Query, something like..
However you can also create a small function in a Module and use the method to be called from your Query too...
Code:
Public Function changeToDate(strDate As String) As Date
'Considering that the Date String you obtain is of this format 12-12-12 (mm-dd-yy)
changeToDate = DateSerial(Mid(strDate, 7, 2), Mid(strDate, 1, 2), Mid(strDate, 4, 2))
End Function
So in your Query you can use it as..
Code:
UPDATE [COLOR=Blue]yourTableName[/COLOR] SET TempDateField = changeToDate([COLOR=Blue][yourCurrentStringDateField][/COLOR])
Paul,
Thank you. I have a follow up question. If I create an update query do I need only the two fields, being the one with the mm-dd-yy format and the tempdatefield? Also do I put the code into the "update to" line of the query in the tempdate field? Thanks.
Okay two things..
1. Have you created the field TempDateField in the table before running the Query?
2. If you have Spaces in your Table name you have to enclose them within square brackets.. so..
Code:
UPDATE [COLOR=Red][B][[/B][/COLOR]Copy Of Parts shipped 2001[COLOR=Red][B]][/B][/COLOR] SET TempDateField = DateSerial(Mid([yourCurrentStringDateField], 7, 2), Mid([yourCurrentStringDateField], 1, 2), Mid([yourCurrentStringDateField], 4, 2))
Paul,
Thank you for your assistance. I really apprectaite it.
Yes I have created that field in the table with the proper data type. When I add the square brackets as below, I still get the same error. Does the TempDateField name have to have brackets as well?
"UPDATE [Copy Of Parts shipped 2001] SET TempDateField"=DateSerial(Mid([PRCDTE],7,2),Mid([PRCDTE],1,2),Mid([PRCDTE],4,2))
Paul,
When I pasted it into the SQL view it put them there. I did remove them and wit the brackets around the table name the query ran.
I did find an error on my part though in the date format. The date is actually format as dd-mm-yy not mm-dd-yy as I originally communicated. My apologies for that. Can a query still work with this other format? Thanks again for your patience ands assistance.
I did find an error on my part though in the date format. The date is actually format as dd-mm-yy not mm-dd-yy as I originally communicated. My apologies for that. Can a query still work with this other format? Thanks again for your patience ands assistance.