Results 1 to 6 of 6

Thread: SQL query

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2002
    Location
    Puerto Rico
    Posts
    29

    Cool SQL query

    Any ideas on how to write a query which verifies availability for an equipment by checking on the date, time and item, to make sure it's not already being used ?

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    How are you going to compare them? by user input or something else?

    if user input then
    let's say you have 3 textboxes date, time and item

    the you could do this to search for a specific item

    SELECT * FROM tablename WHERE date <> '" & txtDate.Text & "' AND time <> '" & txtTime.Text & "' AND item = '" & txtItem.Text & "'"
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2002
    Location
    Puerto Rico
    Posts
    29
    The date will be in an interval (startdate to enddate) specified on two comboboxes, so will be the time.

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    if you want to search between 2 dates and 2 times then it would be

    Code:
    SELECT * FROM tablename WHERE date BETWEEN '" & txtDate1.Text & "' AND '" & txtDate2.Text & "' AND time BETWEEN '" & txtTime1.Text & "' AND '" & txtTime2.Text & "' AND item = '" & txtItem.Text & "'"
    The syntax maybe a little different depending on the database you are using.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2002
    Location
    Puerto Rico
    Posts
    29
    Thanks, but how do you compare the time? Do you have to assign a specific data type to this variable or control so that you can compare what's in the recordset with the users' input?

  6. #6
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    yes, make sure the datatype of the varaible holding the users input is the same as that in the database.
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

Posting Permissions

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



Click Here to Expand Forum to Full Width