You're a genius Igor.

Thank you very much! Much easier than what I was thinking.

Rick

 

-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Igor Tandetnik
Sent: Wednesday, July 08, 2009 12:40 PM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Getting Complete Years Only

Rick Ratchford <r...@amazingaccuracy.com>
wrote:
> Can someone help me with a SQL request?
>
> The Table contains Date, as well as Year, Month and Day columns.
>
> I would like to return a recordset that is made up of only COMPLETE 
> YEARS, from January to December.
>
> Say my data starts on August 14, 1975 and ends with May 4, 2009.
>
> How do I get just those records that start from January 1, 1976 to 
> December 31, 2008, as those would be the only COMPLETE YEARS from 
> January to December in my table?

Perhaps something like this:

select * from myTable
where Year between
    (select min(Year) from myTable where Month=1 and Day=1) and
    (select max(Year) from myTable where Month=12 and Day=31);

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to