Click here to Skip to main content
15,904,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a data row dr a having column PatientcreationDate .Column value while running is
23-04-2013 12:00::00:AM
but i cant read this value using following code.value can be read as string but can't convert to date time

C#
if (DateTime.TryParse(dr["PatientCreationDate"].ToString(), out  TempDate))
           {
               CreationDate = TempDate;
           }


i want value in this field as datetime .Pls help
Posted

1 solution

if you are getting error inside the condition, then convert the string to datetime like
Convert.ToDateTime(TempDate);
 
Share this answer
 
Comments
rajin kp 2-Apr-13 6:29am    
still error
Naz_Firdouse 2-Apr-13 6:42am    
wt error u r getting?
rajin kp 2-Apr-13 7:17am    
String was not recognized as a valid DateTime. PLZ check date format :23-04-2013 12:00::00:AM
Naz_Firdouse 2-Apr-13 7:24am    
hv a look at this...
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/197a243b-1211-44c1-a947-a3375c94b373/
where the datetime column value is assigned to another datetime in C#...
DateTime? value = (DateTime?)resultSet["myDateColumn"];
Hope this helps

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900