SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist tangledman's Avatar
    Join Date
    Sep 2005
    Location
    Puerto de Mazarron, Murcia, Spain
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MSSQL select between dates

    I have datetimes stored in my database as

    YYYY-MM-DD HH:mm:tt

    SELECT * FROM press_coverage
    WHERE press_coverage_date > 2000-01-01
    AND press_coverage_date < 2001-01-01

    ORDER BY press_coverage_date DESC

    Doesn't seem to work.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    697
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    select *
      from press_coverage
     where press_coverage_date > '2000-01-01'
        and press_coverage_date < '2001-01-01'
     order by press_coverage_date desc

  3. #3
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,268
    Mentioned
    116 Post(s)
    Tagged
    1 Thread(s)
    Or
    Code SQL:
    SELECT *
      FROM press_coverage
    WHERE press_coverage_date BETWEEN '2000-01-01' AND '2001-01-01'
     ORDER BY press_coverage_date DESC
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse


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
  •