Thanks! I will try this out and get back to you on how it works for me.

  - cs


--- In [email protected], Dennis Jensen <[EMAIL PROTECTED]>
wrote:
>
> fstrInput = "CR.070813.COG.1-Relocate Exchange Message
> Tracking"
>
> Function DateConvert(fstrInput as string) as string
> Dim strYear as String
> Dim strMonth as String
> Dim strDay as String
> Dim strDate as String
> Dim dteDate as Date
> On Error Goto ErrorHandler
> 'Without testing this I believe Mid sets the first
> 'string value = index 0 but test to me sure you
> 'get what is being expected.
> strYear = mid(fstrInput,3,2)
> strMonth = mid(fstrInput,5,2)
> strDay = mid(fstrInput,7,2)
>
> strDate = strDay & "/" & strMonth & "/" & strYear
> if isdate(strDate) then
> dteDate = cdate(strDate)
> strDate = Format(dteDate,"MM-dd-yyyy")
> else
> call msgbox("Error reading date.")
> strDate = ""
> end if
>
> DateConvert = strDate
> Exit Function
> '
> ErrorHandler:
> Call MsgBox(err.Number & " = " & err.Message)
> DateConvert = ""
> End Function
>
> I do it this way just in case you want to have it do
> different formats in the future. If so then you simply
> need to pass in the FormatType and then encapsulate
> the Format within a Select statement.
>
> --- curtissskeen [EMAIL PROTECTED] wrote:
>
> > How do I take a string of text and convert a portion
> > of it into a date
> > and then display it in a field in MS Acess? For
> > example, if my string
> > is "CR.070813.COG.1-Relocate Exchange Message
> > Tracking" I would like
> > this converted into the date "08-13-2007".
> >
> > (The 4th through 9th letters of my string designates
> > the date of a
> > record, and I would like to isolate it and simply
> > display it in the
> > format "mm-dd-yyy".)
> >
> > Thanks in advance
> >
> > Curtiss Skeen
> >
> >
>
>
>
>
________________________________________________________________________\
____________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now.
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>



Reply via email to