|
 |
asp_databases thread: Inserting a time value into SQL server 7 table
Message #1 by "Julian Fraser" <julian@f...> on Tue, 17 Apr 2001 19:12:53
|
|
I'm having a bit of trouble inserting a time value into my sql
server 7 database. The value being submitted is in the format 'hh:mm' but
it is appearing by default in the database as '01/01/1900 hh:mm:00', table
field is set to shortdatetime. I want the field to just display
the 'hh:mm' value. Can someone help me with a solution to this...?
Thanks,
Julian Fraser.
Message #2 by "Charles Feduke" <webmaster@r...> on Tue, 17 Apr 2001 17:57:39 -0400
|
|
Unfortunately [to the best of my knowledge] you cannot control the
format the data is stored in inside of SQL Server. Even if its
smalldatetime, all the information for it will be stored. You can, however,
CAST or CONVERT the data coming out into whatever format you wish. Try:
SELECT CONVERT(VARCHAR(10), whatever_date, 8) AS whatever_date FROM table
That will output the smalldatetime as hh:mm:ss. That's the closest I
see for SQL 7. Try looking at the CAST and CONVERT topic for your T-SQL
help found in Query Analyzer if available.
You may even be able to define a user-defined type so SQL Server will
store only hh:mm, but I don't have any first hand experience working with
datetime and UDTs.
- Chuck
----- Original Message -----
From: "Julian Fraser" <julian@f...>
To: "ASP Databases" <asp_databases@p...>
Sent: Tuesday, April 17, 2001 7:12 PM
Subject: [asp_databases] Inserting a time value into SQL server 7 table
> I'm having a bit of trouble inserting a time value into my sql
> server 7 database. The value being submitted is in the format 'hh:mm' but
> it is appearing by default in the database as '01/01/1900 hh:mm:00', table
> field is set to shortdatetime. I want the field to just display
> the 'hh:mm' value. Can someone help me with a solution to this...?
>
> Thanks,
> Julian Fraser.
>
|
|
 |