If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > queries of dates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-04, 06:11
noamkrief noamkrief is offline
Registered User
 
Join Date: Dec 2003
Posts: 61
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
Reply With Quote
  #2 (permalink)  
Old 01-03-04, 09:24
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 01-03-04, 18:32
noamkrief noamkrief is offline
Registered User
 
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?
Reply With Quote
  #4 (permalink)  
Old 01-03-04, 18:37
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On