0

See below image, The UpdateDate column show datetime containing 'AM' text But the CreateDate show datetime, text 'PM' is not shown.

these 2 columns are auto-generated, and data type is DateTime. Update Date is :8/19/2010 10:27:20 AM Create Date is :8/13/2010 1:59:00 PM [but PM is not shown]

see image:

1

If PM not shown, '8/13/2010 1:59:00' will be know as '8/13/2010 1:59:00 AM' by C# Code.

The Server is Sql Server R2. It's always ok before any today. Just last nigh shown as below image.

I think the a bug of Sql Server R2.

Could any one tell me why, and how to avoid it happened once more?

Thank you Every Much!

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
  • `SELECT convert(varchar, getdate(), 109)` will use AM/PM or you can use `SELECT convert(varchar, getdate(), 114)` for 24h – Prix Aug 20 '10 at 06:23

1 Answers1

2

DateTime doesn't store neither AM nor PM, it's a generic date and time and will be recognized in C# as such regardless.

If you need AM or PM displayed, that's up to how you let C# or whatever render the output - it's not part of how it's stored (unless you store it as a string). Also, if you don't specify how to format the display/output - it can adapt/change depending on what the server locale is or what the client locale is.

If the screenshot is just from the MS SQL 2008 R2 Management Studio, I've given up on that one for a while, it was incredibly bug-ridden last month.

Oskar Duveborn
  • 10,760
  • 3
  • 33
  • 48