locked
Format date from Access DB RRS feed

  • Question

  • User-623365515 posted

    Hey guys :)

    I want to read the date from a Access Database and format it.. 

    when I do a normal read on the date field this comes out :

    05.02.2012 00:00:00

    but I want to cut the time "00:00:00" away.. 

    how do I do that? xD

    Thanks in advance

    Benedikt

    Friday, February 3, 2012 3:27 AM

Answers

  • User3866881 posted

    Hello BoEndD:)

    1)Try to change your specific column's type to DateTime。

    2)Then try to do this——suppose columnName is the specific column name of your db,and reader is SqlDataReader——

    ((DateTime)reader["columnName"]).ToString("HH:MM:ss");
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 4, 2012 8:45 PM

All replies

  • User197322208 posted

    <yuordatetime>.ToString("dd.MM.yyy")

    Friday, February 3, 2012 4:13 AM
  • User-623365515 posted

    i did it like this : 

    @thisReader["Enddatum"].ToString("dd.MM.yyy")

    and he gives me a CS1501 error.. :(

    Friday, February 3, 2012 4:17 AM
  • User197322208 posted

    @thisReader["Enddatum"].

    this is not a datetime. IF you are you sure in the database is a datetime, then you can try to convert to datetime. ( add tostring, then DateTime.parse)

    Friday, February 3, 2012 4:49 AM
  • User-623365515 posted

    so can you give me code example? I'm not into this coding at all ^^

    Friday, February 3, 2012 5:03 AM
  • User3866881 posted

    Hello BoEndD:)

    1)Try to change your specific column's type to DateTime。

    2)Then try to do this——suppose columnName is the specific column name of your db,and reader is SqlDataReader——

    ((DateTime)reader["columnName"]).ToString("HH:MM:ss");
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, February 4, 2012 8:45 PM
  • User-623365515 posted

    mmhh I'm using OleDbDataReader.. does your code will still work with that?

    Monday, February 6, 2012 4:58 AM
  • User3866881 posted

    mmhh I'm using OleDbDataReader.. does your code will still work with that?

    Yes,it should work。

    Monday, February 6, 2012 7:04 AM