Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    7

    Unanswered: Trouble using sysdate in BETWEEN clause

    The following query returns no results, when there should be many. Can anyone tell me what I'm doing wrong?

    SELECT latitude, longitude
    FROM data_hist
    WHERE server_ts BETWEEN sysdate() AND sysdate() - 100000
    ORDER BY server_ts ASC

    Thanks in advance!

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Not sure what you mean by subtracting an integer (100000) from a date. You'd do better using the date_add function.

    Mike

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by attrcat
    Can anyone tell me what I'm doing wrong?
    it's hard to tell from what little information you've provided

    please do a SHOW CREATE TABLE

    also, i'm curious how a lat/long data point would be time-sensitive
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    a lat/long reflects a physical co-ordinate which may have been recorded at a specific point in time as a position.

    I don't see any problem in looking for positions over a specific date/time span.
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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