R,
>I tried using the following query, but it list sometimes 13 months
>when the current date is in the middle of the month.
SELECT * FROM t WHERE DATE_ADD(dt, INTERVAL 1 YEAR) >= NOW();
Try...
DATE_ADD( dt, INTERVAL
IF(YEAR(NOW())%4>0 AND YEAR(NOW())%100=0,366,365)
DAY ) >= NOW()
PB
-----
grKumaran wrote:
>Hello,
>
>CREATE TABLE t (
>dt datetime
>)
>
>Please assume this is the table structure and contains thousands of records.
>And I want to list them only last 12 months (that mean last 1 year) records
>exactly.
>
>For that I tried using the following query, but it list sometimes 13 months
>when the current date is in the middle of the month.
>
>SELECT * FROM t WHERE DATE_ADD(dt, INTERVAL 1 YEAR) >= NOW();
>
>I request you to help me. And thanking you for the consideration.
>
>Sincerely,
>R.Kumaran
>
>
>
>
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.2/137 - Release Date: 10/16/2005