Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Location
    Maryland
    Posts
    152

    Unhappy Unanswered: Time Part of field

    Hi,

    I have a very beginer's question. I am trying to compare datetime field with time only. how can i just compare with time?

    Select start_time,end_time from tblvouchers as sv,tblvoucherlines as svl
    where sv.voucher_no = svl.voucher_no and
    sv.equip_no = '01325' and svl.line_date ='03/14/2004'
    and svl.start_time = '18:00' and svl.end_time = '00:00'

    this query is not displaying any data.

    Any help will be highly appreciated.
    mr_roomi

  2. #2
    Join Date
    Sep 2004
    Posts
    22
    This here...

    ***
    svl.start_time = '18:00' and svl.end_time = '00:00'
    ***

    will only show times that are exactly starting at 6 AND ending at midnight.
    Wouldn't you want a range of time regardless of the endtime? IE:

    svl.start_time >= '18:00' and svl.start_time <= '00:00'

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    And...

    Code:
    SELECT CONVERT(varchar(8),GetDate(),108), CONVERT(varchar(8),GetDate(),101)
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  4. #4
    Join Date
    Mar 2004
    Location
    Maryland
    Posts
    152

    worked

    Hi,

    Michell, thanks, it worked.

    Hey Brett, been long time? thanks for reply
    mr_roomi

  5. #5
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Be careful though...time is still made up of date AND time...

    You should either use CONVERT or use a DATE Function like DATEDIFF
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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