locked
Date from DB goes into Label with time RRS feed

  • Question

  • User1535393768 posted
     
    Using reader As OleDbDataReader = cmd.ExecuteReader()
                        While reader.Read()
                            IDateLabel.Text = DateTime.Parse(reader("Idate")).Date.ToString("mm/dd/yyyy")
                        End While
    End Using
    The code above works but it's not getting rid of the time.  No matter what format syntax I use, it doesn't want to listen.  It always gives me 6/13/2012 12:00:00.  I want only the date and not the time.  Any help?
    LMB
    Wednesday, June 13, 2012 4:36 PM

Answers

  • User1535393768 posted

    DateTime

    .Parse(reader("Idate"

    ))

    My bad... this is what fixed it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 14, 2012 11:01 AM

All replies

  • User197322208 posted

    maybe it is not any record? Do you assign first a date to

    IDateLabel
    ?
    Wednesday, June 13, 2012 4:40 PM
  • User-1528094326 posted

    SQL Server would have a data type called "Date" but Access only has DateTime it seems for Office 2007.

    http://msdn.microsoft.com/en-us/library/bb208866(v=office.12).aspx

    Wednesday, June 13, 2012 4:40 PM
  • User1535393768 posted

    IDateLabel is the name of an empty label that I am dumping the Date into.  This works perfect but showing the time with my date which is not wanted. 

    I am pulling a short date from an Access database like 2/12/2012 but when I put it in my label (no matter the formatting) it shows up as 2/12/2012 12:00:00 AM.  I just want only the date and not the time.

    Wednesday, June 13, 2012 4:43 PM
  • User1535393768 posted

    DateTime

    .Parse(reader("Idate"

    ))

    My bad... this is what fixed it.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 14, 2012 11:01 AM