Click here to Skip to main content
15,889,651 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
my data row for data table contain date in a format
dd-MM-yyyy hh:mm::ss:AM
check Two '::' symbol after minutes. I can't convert /read this value as datetime is there any solution for this it always throw invalid date formatt PLz help
Posted
Updated 2-Apr-13 0:50am
v2
Comments
Madhav Hatwalne 2-Apr-13 6:51am    
Do you want to show minutes or not?
You are inserting a value or displaying?
ZurdoDev 2-Apr-13 7:11am    
You need to post the relevant code.
rajin kp 2-Apr-13 7:14am    
if (DateTime.TryParse(dr["PatientCreationDate"].ToString(), out TempDate))
{
CreationDate = TempDate;
}
iam reading data from data table .Convert.ToDateTime() not working

Corrected my code to your format . Tested it and working:

C#
DateTime date;
if (DateTime.TryParseExact("21-01-2009 14:59::59:PM", "dd-MM-yyyy HH:mm::ss:tt", CultureInfo.GetCultureInfo("en-GB"), DateTimeStyles.None, out date))
{
   MessageBox.Show("Success");
}
 
Share this answer
 
v2
Comments
rajin kp 3-Apr-13 1:58am    
@Dionisios Karatzas
when i connected to other database such problems for date doesn't come. i am using Collation Arabic_CI_AS.Is it related to database. plz give some useful link.plz explain reason
C#
if (DateTime.TryParse(dr["PatientCreationDate"].ToString().Replace("::",":"), out  TempDate))
            {
                CreationDate = TempDate;
            }

Happy Coding!
:)
 
Share this answer
 

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