Results 1 to 3 of 3

Thread: Picking all times on a certain day

  1. #1
    Join Date
    Mar 2005
    Posts
    2

    Picking all times on a certain day

    I am having trouble with this query:

    Declare @day datetime
    Set @day = getdate()
    Declare @day_end datetime
    Set @day_end = DateAdd(second, -1,DateAdd(hour, 24, @day))

    Select rowid, Substring(Convert(varchar(20), date_time_slot), 14, 6) As timeslot, available From tbl_thresholds Where queue = @queue And date_time_slot between @day And @day_end

    The date_time_slot is a datetime field. If I take out the between statement I get data, but with it in I get nothing.

    Any ideas why?

  2. #2
    Join Date
    Feb 2003
    Posts
    1,048
    There must not be any data values in date_time_slot that are between @day and @day_end.

  3. #3
    Join Date
    Mar 2005
    Posts
    2
    Yeah, I just found the problem. The person who created the table when populating the date_time_slot field accidentally set the year to 2002 instead of 2005. Thanks for the help.

Posting Permissions

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