Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    1

    Unanswered: view results per hour for TODAY

    I am trying to view the records in a table for each hour during the day
    if I do somthing like.

    SELECT TimeIn FROM V6STN1
    WHERE TimeIn BETWEEN '2003-12-05 07:00:00.000' AND '2003-12-05 07:00:00.000'

    I can get the results for the Hour 05/12/2003 but I want to get the results for

    BETWEEN (TODAY 07:00:00.000) AND (TODAY 08:00:00.00)

    is there any way that I can use GETDATE() to return only the date and not the time and then combine the results of this with 07:00:00.000 and 08:00:00.000 to give the required results

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Check DATEPART function in BOL.

  3. #3
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    drop table test1
    create table test1
    (col1 varchar(10))
    insert into test1 values (' 07:00:00')
    insert into test1 values (' 08:00:00')
    insert into test1 values (' 09:00:00')
    insert into test1 values (' 10:00:00')

    select convert(varchar(10), getdate()) + col1
    from test1

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    heh heh heh. Er. Make that convert(varchar(11), getdate()). I seem to be missing a 0.

Posting Permissions

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