saurabh goyal
saurabh goyal

Reputation: 1744

Datetime in 24 hour format

my type for date in the database is datetime and format of the datetime i am getting is 2/21/2011 12:00:00 AM .how can i convert this into 24 hour format.

Upvotes: 0

Views: 4244

Answers (2)

reggie
reggie

Reputation: 13711

Rather than changing the storage mechanism of the data in table, when you displaying the data, use the format you want and show it in your User Interface. Something like this:

DateTime.Parse(dateTime).ToString("MM/dd/yyyy HH:mm")

Upvotes: 4

MatBailie
MatBailie

Reputation: 86706

From the comments I would suggest that you may have a mis-understanding.

After you enter datetime data into a database, it's not stored as text, it's not stored as AM/PM or 24 hour, it's its own type. Only when an application converts it for display on screen does the difference materialise. This is an artefact of the application, not the database.

Are you able to eloborate on why this is an issue to you? How is the data being used?
- Are you going to be running any code?
- Are you copying it to Excell?
- Are you just basking in it's glory?

Upvotes: 2

Related Questions