Link to home
Start Free TrialLog in
Avatar of JohnHockett
JohnHockett

asked on

Remove some characters from a String when returned with SqlDataReader GetString.

Can someone help me with removing the time part from this string "8/15/2005 12:01:00 PM".  I just want to show the date.  The database column is a "char" and I am using the SqlDatareader GetString to return "8/15/2005 12:01:00 PM".

here is part of the code that diaplays the string on the page:

Private Sub AddRecord(ByVal MyDocument As Document, ByVal Data As SqlDataReader)
        'Adds a new MyPage to the MyDocument if needed
        If currentY > bodyBottom Then AddNewPage(MyDocument)

        'Adds alternating background to MyDocument if needed
        If alternateBG Then
            currentPage.Elements.Add(New Rectangle(0, currentY, 504, 18, New WebColor("E0E0FF"), Apply.Fill))
        End If

        'Adds Labels to the MyDocument with data from current record
        '(0)CCID, (1)CCFName, (2)CCLName, (3)CCAddress, (4)CCCity, (5) CCState, (6)CCZip, (7)CCPhone
        '(8)CCEmail, (9)CCName, (10)CCType, (11)CCNumber, (12)CCExpMonth, (13)CCExpYear,(14)CCCVV2,
        '(15)CCAmount, (16)CCPolNumber, (17)CCDateTime, (18)CCProc, (19)CCProcBy, (20)CCProcDate
        '(21)CCDeclined, (22)CCReason
(here is where I would assume the "trimming" would occur, but I cannot find the documentation to help out on this...)
         currentPage.Elements.Add(New Label(Data.GetString(17), 2, currentY + 2, 100, 11, Font.TimesRoman, 11))
       

        'Toggles alternating background
        alternateBG = Not alternateBG
        'Increments the current Y position on the MyPage
        currentY += 18
    End Sub

I can provide more info if needed,

Thanks
Avatar of Tim_Heldberg
Tim_Heldberg

Private Sub GetDate(date as String) as String
  dim index as Integer
  dim datepart as String
  index=InStr(date," ")
  datepart=left(date,len(date)-index)
  GetDate=datepart

end sub

I am not 100% sure on the VB syntax, by this is what you want to do
ASKER CERTIFIED SOLUTION
Avatar of bnanitha
bnanitha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial