Hi ,
I am converting MM/dd/yyyy date to yyyy-MM-dd hh:mm:ss using dateobject.ToString("yyyy-MM-dd hh:mm:ss").
Its converting perfectly in given format but in MM-dd-yyyy format there is no hour specified and hour is appearing in this yyyy-MM-dd hh:mm:ss format .
For e.g. date is 05/07/2009 i.e. 7 May 2009 and after converting to yyyy-MM-dd hh:mm:ss format, date is appearing as 2009-05-07 12:00:00.
From where this 12 is appearing ? We don't want this 12 . The date should display like 2009-05-07 00:00:00.
Please suggest solution.
Thanks
Prasad
Loading

VulpesRank #55 · 29.2K reputationPosted May 2, 2011, 3:05 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 2, 2011, 3:23 AM EDT
Abhimanyu K VatsaRank #14 · 51.7K reputationPosted May 2, 2011, 3:24 AM EDT
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Prasad Godbole153 reputationPosted May 2, 2011, 3:53 AM EDT
Thanks for giving solutions.
I used 24 hours date format and now hour is appearing 00.
Thanks again
Kind Regards
Prasad
Abhimanyu K VatsaRank #14 · 51.7K reputationPosted May 2, 2011, 4:15 AM EDT
thanks
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted May 2, 2011, 4:31 AM EDT
Do like this::
string @DOB = DateTime.ParseExact(txtDOB.Text, "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentUICulture. DateTimeFormat).ToString("MM/dd/yyyy");
Otherwise post the code here...
Jiteendra SampathiraoRank #585 · 4.1K reputationPosted May 2, 2011, 4:41 AM EDT
Go through these links:
http://www.sql-server-helper.com/tips/date-formats.aspx
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx