Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    1

    Unanswered: How to View only Time in SQL?

    hi.. i'm using sql server 7.0 and visual basic 6.0 to develop a system for a project in one of the module that i'm studying. i've encountered 2 problems here.. hope someone here can help me..

    1. this is one of the table in the database..

    Create Table RepairRecord
    (RR_Id char(10) Not Null,
    RDate datetime Not Null,
    RTime datetime Not Null,

    PartName varchar(20),
    PartCost decimal(7,2),
    Description varchar(50),
    ENG_Id char(10) Not Null,
    SA_Id char(10) Not Null,
    Primary Key (RR_Id),
    Foreign Key (ENG_Id) References Engineer(ENG_Id),
    Foreign Key (SA_Id) References ServiceAgreement(SA_Id));

    is the attributes highlighted in bold correct? and in RTime, i've declared the datatype as datetime.. but actually i just want it to show only time.. how do i do that?

    2. there's a requirement that we need to give our lecturer a soft copy of this whole system. well, just don't want to waste any CD-R, how to burn everything in the cd and it will work fine using the cd itself? i once tried to burn one but can't run cos it said can't find database...

    well.. visual basic is the front-end while sql is the back-end..
    so, anyone can help??

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'd use a single column to store both the date and time. You can easily manage the display of one or the other, or both. It makes all kinds of temporal (time based) code simpler if you leave the date and time together.

    As for the issue of the CD, a database can be made readable on CD, but that has very limited usage simply because it is read only. You can detach or backup a database and burn the files to a CD, but they need to be copied/restored back to disk to be fully usable. Using a CD-R would be a performance disaster, but it might work. It is tough to give you much guidance without a lot more insight into what you are actually trying to do.

    -PatP

  3. #3
    Join Date
    Feb 2004
    Location
    San Antonio, TX
    Posts
    565
    you can do anything with this that you need but it just breaks the time up into smaller peices

    create table TimeTest
    (
    c1 datetime
    )

    insert into timetest values (getdate())
    WAITFOR DELAY '00:00:4'
    insert into timetest values (getdate())
    WAITFOR DELAY '00:00:4'
    insert into timetest values (getdate())
    WAITFOR DELAY '00:00:4'
    insert into timetest values (getdate())
    WAITFOR DELAY '00:00:4'
    insert into timetest values (getdate())

    select convert(varchar(5),DATEPART(hh,C1))
    +':' + convert(varchar(5),DATEPART(n,C1))
    + ':'+ convert(varchar(5),DATEPART(ss,C1))
    + ':'+ convert(varchar(5),DATEPART(ms,C1)) as 'funkytime' from timetest

    --drop table timetest
    --truncate table timetest

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •