c# - Can't convert from String to Char -
i'm trying split string: 2015-08-14 20:30:00
but compiler shows message:
can't convert string char
this code:
string date = reader["date"].tostring().split("-").tostring();
the variable reader["date"]
object, must convert string. want split content 3 other variable this:
year: 2015 month: 08 day: 14
what doing wrong?
sometime different approach should considered. if reader field datatype date or datetime using correct datatype correct way handle info. datetime has need.
datetime dt = convert.todatetime(reader["date"]); int year = dt.year; int month = dt.month; int day = dt.day;
Comments
Post a Comment