Problem saving 24 hour date/time in SQL

  • Thread starter Thread starter JL
  • Start date Start date
J

JL

I have an SQL table(MS SQL 2005) with a field called SignInDate and
have created this as DateTime. When I save the current time using the
Now function, it does not save the value in 24 hour format.

For example, if it is 2:15:36 PM (i.e. 14:15:36) it saves the value in
SQL Sever as 2007-03-08 02:15:36.000 and when I read it back, it
resuls in 2:15:36 AM.

I have tried formatting as a string using HH:mm:ss for the time
portion but SQL Server still saves as shown above. How can I get it to
save as 2007-03-08 14:15:36.000 so it will be correct when I read it
back?

TIA,
John
 
As a side note you make a confusion between formatting and the real value
that is stored in a DB. A database won't preserve formatting. Data are just
stored using an internal representation.

Values are *displayed* (not stored) according to formatting rules. This is
usually done at client application side (for example to allow for formatting
the same data according to user's national rules).
 
Back
Top