0

I'm trying to only show the date portion of a string field. This is the format of the string: STARTED:/ 03/23/1983 TIME:/ 03:12

I need to remove "STARTED:/" and "TIME:/ 03:12" and only show the date portion of the string:03/23/1983. What formula can I use to do that?

Thanks

Ryan
  • 7,212
  • 1
  • 17
  • 30
Dagz200
  • 221
  • 7
  • 15
  • 25

2 Answers2

1

I have used this formula to split the string of Full Name into "Last Name", rest of the string is concatenated as "First Name"

        Dim string_array() As String
        Dim i As Integer = 0
        Dim ContactName As String = dt(0)("ContactName").ToString()
        Dim contact_name As String
        contact_name = String.Empty
        If ContactName.Length = 0 Then
            contact_name = String.Empty
        Else
            string_array = Split(ContactName, " ")
            If string_array.Count > 1 Then
                For i = 0 To string_array.Count - 2
                    If string_array(i) = String.Empty Then
                        Continue For
                    End If
                    contact_name = contact_name & " " & string_array(i)
                Next
            Else
                contact_name = ContactName
            End If
        End If
DareDevil
  • 5,249
  • 6
  • 50
  • 88
0

The Crystal Reports help file is your friend and should be your first stop for simple questions on built-in functions and data types.

In CR strings are just stored as character arrays so you can access them like arrays - by index. So in your case, if you will always have the same string format (that is, the same number of characters, leading zeroes, etc.) then you can do something like this:

local stringvar mystr := {table.your_string}; //mystr:="STARTED:/ 03/23/1983 TIME:/ 03:12"
mystr[11 to 20] //return "03/23/1983"

Alternatively, you could use the Mid() string function.

Ryan
  • 7,212
  • 1
  • 17
  • 30