Thread: DateDiff

  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Rep Power


    hi. i need some help[ here.

    how do i use the DateDiff function to select data that are posted in the last two weeks only [given all rows entered had a timestamp field]
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Woodland Hills, Los Angeles County, California, USA
    Rep Power
    You can use GETDATE() to get the current datetime and DATEADD() with a negative offset to get a date two weeks ago, something like this:

    SELECT * From Table
    WHERE LogDate >= DATEADD(DAY, -14, GETDATE())
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo