[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Time field in SQL Server 6.5

Posted on 1998-12-07
4
Medium Priority
?
197 Views
Last Modified: 2010-03-19
I'm trying to migrate a MSAccess database to SQL Server 6.5 In MsAccess I have 2 time fields defined as "short time".
I just realized there is no such datatype in SQL Server. Is there a way to handle this using the "small datetime" type?

If you know the answer, please post an example, as I'm not very familiar with SQL Server

Help appreciated,

Ion
0
Comment
Question by:iamari
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
Victor Spiridonov earned 800 total points
ID: 1092116
There is only datetime and small datetime field in SQL Server, that consists of date and time. there is no date or time datatypes. you should use either character field or datetime and CONVERT function to return only time part of datetime.
0
 
LVL 2

Author Comment

by:iamari
ID: 1092117
The problem is not so much how to display only the time, but how to insert only time from a web form? The user will just type something like 23:15

Can the CONVERT function be used to do this? How?

Ion
0
 
LVL 7

Expert Comment

by:Victor Spiridonov
ID: 1092118
You can insert just '23:15', it will default to 1/1/1900 23:15 there is no way to have only time.
Example:
create table test (tt datetime )
go
insert into test values ('23:15')
select * from test
Result:
(1 row(s) affected)

tt                          
---------------------------
1 Jan 1900 23:15            

(1 row(s) affected)
0
 
LVL 2

Author Comment

by:iamari
ID: 1092119
Thanks a lot, it works!

Ion
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

826 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question