Thread: DateDiff

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

    Join Date
    Aug 2003
    Posts
    75
    Rep Power
    11

    DateDiff


    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
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    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