I am using SQL Server 2008 and I have a database file (mydata.mdf) in which I have a column in one of the table and that column has the datatype (Time) .
I added this database file to my WPF-C# project (using VS2010) , but I had a problem and its as follows :
This (Time) column treats time in 24-Hours system , but I want to use (12-Hour) system in my application , so is there a way to define a 12-Hour system time in SQL server2008 .
and if there isn’t , what do you think is the best way to handle that ???
Pleeeeeeeeeeease help me ASAP because I’m in a hurry and I can’t figure it out …
The time in the database is not “formatted”. It is represented in some internal format (which you can Google for but shouldn’t care about) that allows it to represent each moment in the day, to the supported level of precision.
The values are only formatted when your application converts them to strings for the purpose of displaying them to the user, and you have full control over this.
So if you have read a time into an instance of the CLR DateTime class, you can display as a 12-hour time (omitting the date) with value.ToString(“h:mm:ss tt”). Custom formatting options are listed here.