List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:July 30 1999 8:03pm
Subject:Re: Date search
View as plain text  
On Fr, 1999-07-30 10:29:28 -0400, Sweeney, Darren L wrote:
> I'm struggling I'm afraid, even after extensive manual research. 

Hmm, extensive?  Well, maybe you've an older version of MySQL, but
from V3.22.x on there's a whole chapter in the manual:
  "7.3.11 Date and time functions",
and there you easily should find the functions DATE_ADD() and
DATE_SUB() ...

> What I need to do is search the date field in my db for dates which
> are more than 2 days ago but less than 4 days ago.

For date or time ranges best use BETWEEN; try something like that:

  date BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL 4 DAY)
           AND DATE_SUB(CURRENT_DATE, INTERVAL 2 DAY) 

Note: you maybe have to write DAYS, but my V3.22.19b only accepts DAY.

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
Date searchDarren L Sweeney30 Jul
  • Re: Date searchMike Hanney30 Jul
  • Re: Date searchMartin Ramsch31 Jul
RE: Date searchDarren L Sweeney30 Jul
  • RE: Date searchDon Read1 Aug