c# - Converted a object List to DateTime List but I just want the Date not the Time -
this question has answer here:
i have object list called list , converted by:
list<datetime> datelist = list.select(date => convert.todatetime(date[0])).tolist();
my object list contained values such 09/04/2015 when list conversion values in format of 09/04/2015 00:00:00.
i wondering how can date stored in datelist?
the .date property not work
.net doesn't have type represents just date
. however, if know how want date displayed @ point in code, can convert string.
const string dateformat = "d"; // e.g. "9/4/2015" list<string> datelist = list .select(date => convert.todatetime(date[0]).tostring(dateformat)) .tolist();
you can change dateformat
use of standard strings listed here, or using custom format can build, described here.
Comments
Post a Comment