how to find a substring in a string in access?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

which command should I use to find the lenght of a specific character in a
string?
Ex: I have a date like this "21-9-2005-16:24" and because of the "-"
between the year and the hour access don't recognize it as a date, I'm
planning to find the "-" and delete it.

Is that the best way to do it?? what should I do??

thanks in advance
 
You can use this function in the query, that except the string and return a
date field
removing the dash

Function ChengeDateField(MyDate As String) As Date
ChengeDateField = Left(MyDate, InStrRev(MyDate, "-") - 1) & " " &
Mid(MyDate, InStrRev(MyDate, "-") + 1)
End Function

Select DateFieldName, ChengeDateField(DateFieldName) as NewDate From TableName
 
Back
Top