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

Re: Problem saving 24 hour date/time in SQL by JL

JL
Thu Mar 08 13:29:11 CST 2007

Opps...never mind. I was changing the format later in my code by
mistake.

John
On Thu, 08 Mar 2007 10:34:03 -0800, JL <john@marymonte.com> wrote:

>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


Re: Problem saving 24 hour date/time in SQL by Patrice

Patrice
Fri Mar 09 07:09:39 CST 2007

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).


"JL" <john@marymonte.com> a écrit dans le message de news:
fvo0v2hban34uimmv2mmmeteu5htv5e4hl@4ax.com...
> Opps...never mind. I was changing the format later in my code by
> mistake.
>
> John
> On Thu, 08 Mar 2007 10:34:03 -0800, JL <john@marymonte.com> wrote:
>
>>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
>