Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

string cutting

HaileaHailea Member Posts: 2
Hallo,

Sorry for my englisch.

I have a string/varchar with variable length.
Example => <<<<<<<<<<05/10>>>>>>>>>>
or
<<<<<<<<<<<<<<<<<<<01/02>>
.
And now i want just the date.
How can i do that?

Greets.

Comments

  • dokken2dokken2 Member Posts: 532
    : Hallo,
    :
    : Sorry for my englisch.
    :
    : I have a string/varchar with variable length.
    : Example => <<<<<<<<<<05/10>>>>>>>>>>
    : or
    : <<<<<<<<<<<<<<<<<<<01/02>>
    : .
    : And now i want just the date.
    : How can i do that?
    :
    : Greets.
    :


    here's two ways-
    1- if your date is always hard-coded in "01/07" format
    2- can parse the entire string, looking for numeric or "/" values

    Const myString = "<<<<<<<<<<05/10>>>>>>>>>>"
    Dim tmp As String
    Dim myPosition As Integer

    'hard-code, if your date is always in "01/07" format
    tmp = ""
    'find "/" character
    myPosition = InStr(myString, "/")
    'get 2-chars before/after "/"
    tmp = Mid(myString, myPosition - 2, 5)
    MsgBox tmp


    'parse, find your date in string of chars
    Dim i As Integer
    Dim char As String * 1
    tmp = ""
    'loop thru string
    For i = 1 To Len(myString)
    'get one char
    char = Mid(myString, i, 1)
    If IsNumeric(char) Then tmp = tmp & char
    If char = "/" Then tmp = tmp & char
    Next
    MsgBox tmp
Sign In or Register to comment.