SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Oct 2001
    Posts
    359
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    adding date onto existing date for a where clause

    wanting to gather rows that dateFoo is not the same as dateBar + day(1) tried using DATEADD without any success, for example: select * from table where dateFoo != DATEADD(dayofyear, 1, dateBar) but get the error back: Syntax error: Data Type "dayofyear" does not match Defined Type name. also tried a + 1, but that seems to only work on oracle and not sql.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    http://dev.mysql.com/doc/refman/5.5/...ction_date-add
    Code:
    select * 
    from table 
    where dateFoo <> DATE_ADD(dateBar, INTERVAL 1 DAY)

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,218
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    ... WHERE dateFoo <> DATEADD(day,1,dateBar)

    of course, that'll only work if dateFoo and dateBar are actual DATE or DATETIME columns


    p.s. guido, it's microsoft sql server
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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