asp.net - Date format sorting issue -
i using asp.net 2005 on system , creating application. have issue date format sorting. have table including 3 fields "user name, date time, visit page".
my records below
user name date time visited page xyz 4/4/2013 5:30:45 pm aaa.aspx xyz 4/4/2013 6:35:15 pm aaa.aspx xyz 4/4/2013 7:55:45 pm aaa.aspx xyz 4/4/2013 10:05:45 pm aaa.aspx xyz 4/4/2013 11:06:45 pm aaa.aspx
i want sorted without using java script or jquery. , output should
user name date time visited page xyz 4/4/2013 11:06:45 pm aaa.aspx xyz 4/4/2013 10:05:45 pm aaa.aspx xyz 4/4/2013 7:55:45 pm aaa.aspx xyz 4/4/2013 6:35:15 pm aaa.aspx xyz 4/4/2013 5:30:45 pm aaa.aspx
but got output this
user name date time visited page xyz 4/4/2013 7:55:45 pm aaa.aspx xyz 4/4/2013 6:35:15 pm aaa.aspx xyz 4/4/2013 5:30:45 pm aaa.aspx xyz 4/4/2013 11:06:45 pm aaa.aspx xyz 4/4/2013 10:05:45 pm aaa.aspx
i tried sorted via dataview not working can 1 me out issue.
there many other ways read csv, including raw text file , simple string parsing. can use of suggestions in other answers here, or can populate results datatable, or whatever. use whatever comfortable with.
the important bit hasn't been mentioned in other answers need explicit datetime format reading. example, how know 1/2/2013
represents either january 2nd, or february 1st?
since file have not using invariant date format (like iso8601 example), should somewhere explicitly providing format, such as:
datetime dt = datetime.parseexact(yourdatestring, "m/d/yyyy", // or "d/m/yyyy" cultureinfo.invariantculture);
Comments
Post a Comment