Hi All,
I have problem converting string to DateTime datatype.
I am using Convert.ToDateTime(string) method but its not working
Can anyone please help me with it.The value returned by the method has to be passed as input parameter into a stored procedure ,the datatype of the input parameter is dateTime.
Please help me
Thanks
jyoti
shivendraPosted Jul 21, 2005, 8:41 AM
U Use this Way I think It Should Work:
string Hello = "";
Convert.ToDateTime(Hello).ToShortDateString();
Ok Bye -Bye
Ratna SatishPosted Jul 21, 2005, 5:42 AM
i think you are getting problem because, your culture info is en-US and you are sending date in dd/mm/yyyy format. i am giving a simple example here in vb.net , if it is good, u try it in c#.
Imports
System.Globalization Dim strDate As String = "31/10/2005" '(dd/MM/yyyy) ' if we are not using this , it is treated as 'mm/dd/yyyy' format.Dim myCulture As New CultureInfo("en-GB")
Dim dateMyDate As DateTime
dateMyDate = Convert.ToDateTime(strDate, myCulture)
MsgBox(dateMyDate.ToString())
Posted Jul 21, 2005, 12:44 AM
string dtstring = "01/01/2005";
DateTime xx = Convert.ToDateTime(dtstring );
Console.WriteLine (xx.ToString() );
killingseedPosted Jul 14, 2005, 7:19 PM
have you looked into datatime.parse
string myDateTimeValue = "2/16/1992 12:15:12";
DateTime myDateTime = DateTime.Parse(myDateTimeValue);