Reputation: 800
I have datetime column in sql server and its 24hr format. But when I execute the query to fetch the data and store that in a dataset its showing 12hr format. I need the same format as in database.
Please help.
Upvotes: 0
Views: 937
Reputation: 1050
values in a datetime column are stored as number of days since 01.01.1900 (4 byte) and number of clock ticks since midnight (4 bytes) ... it has nothing to do with 24hr/12hr format ... that is just a matter of what you do with the date values (affected by regional settings etc) ...
Upvotes: 0
Reputation: 2293
In Global.asax
using System.Globalization;
using System.Threading;
//...
protected void Application_BeginRequest(Object sender, EventArgs e)
{
CultureInfo newCulture = (CultureInfo) System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
newCulture.DateTimeFormat.FullDateTimePattern = "dd/MMM/yyyy HH:mm:ss";
newCulture.DateTimeFormat.DateSeparator = "-";
Thread.CurrentThread.CurrentCulture = newCulture;
}
Upvotes: 2