Reputation: 635
When I run a stored procedure in SQL Server 2008 CTP I get date "2012-10-31 00:00:00.000"
with this format.
But when I am converting it using
Convert.ToString(drConversation["ConversationDate"])
in C#, I am getting "10/31/2012 12:00:00 AM"
.
Where should be problem? In C# code or in SQL Server?
Upvotes: 0
Views: 970
Reputation: 14460
Try this way
DateTime mydate= Convert.ToDateTime(drConversation["ConversationDate"].ToString());
Upvotes: 0
Reputation: 17385
Actually it is the same date but in a different format.
If you would like to see it in the same format as in the Sql Server you can use:
DateTime.Parse(drConversation["ConversationDate"].ToString()).ToString("yyyy-MM-dd HH:mm:ss")
Upvotes: 1
Reputation: 263683
There is no problem with it, The SQLServer use 24-hr format
while the output from Convert class outputs 12-hr format
.
Upvotes: 1