Bruce Therrien wrote:

Using a select statement, how does one
select all records that have a date one day
less than the current date? Our database has these fields:


EMAIL, AMOUNT, ID, DATE

The date is in format 00/00/0000

Gack. I'm guessing "00/00/0000" is a string?


1) "DATE" is a MySQL reserved word, a data type, meaning a date in
   "YYYY-MM-DD" format.

2) MySQL has date functions, but they require a real date field to
   operate on :-)

So: CREATE myTable ( myDate DATE );

Then you can simply

SELECT myDate FROM myTable WHERE myDate = DATE_SUB(NOW(), INTERVAL '1' DAY);

Refs:
  <http://www.mysql.com/doc/en/Date_and_time_types.html>
  <http://www.mysql.com/doc/en/Date_and_time_functions.html>

HTH!
--
Hassan Schroeder ----------------------------- [EMAIL PROTECTED]
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

dream. code.




-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to