Chirag Khatsuriya
Chirag Khatsuriya

Reputation: 635

Date format Issue in SQL Server or ASP.NET

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

Answers (3)

huMpty duMpty
huMpty duMpty

Reputation: 14460

Try this way

DateTime mydate= Convert.ToDateTime(drConversation["ConversationDate"].ToString());

Upvotes: 0

Blachshma
Blachshma

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

John Woo
John Woo

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

Related Questions