Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2003
    Posts
    61

    Unanswered: queries of dates

    I want to run queries on entries with certain dates....

    I want the query to come up with entries which are bigger than 02/09/1982


    I'm assuming I do:
    SELECT * FROM ME WHERE ME.DATE<DATE()
    (i tried this in msaccess -didn't work )

    Now, how do i do a query that will result in all entries that their DATE filed is between now and the past 60 days?

    Thanks
    Noam

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you'll need to be a bit more specific

    do you want dates greater than 02/09/1982, or dates between now and the past 60 days?

    also, what database do you want this for, mysql or access?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Dec 2003
    Posts
    61
    sorry...
    MYSQL
    And i want to know how to do both...

    I think for the first one "anything above 02/09/1982" I need

    SELECT * FROM ME WHERE ME.DATE>'02/09/1982'


    Then i need one that would do the past 60 days....

    Do can i subtract NOW() - 60????
    Would that work?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    1. mysql recognizes dates only in year/month/day sequence

    ... WHERE ME.DATE > '1982-02-09'

    2. perform the calculation on CURRENT_DATE

    ... WHERE ME.DATE > DATE_SUB(CURRENT_DATE, INTERVAL 60 DAY)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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