[Gambas-user] sql query year problem
Rob Kudla
sourceforge-raindog2 at ...94...
Mon Mar 6 04:35:28 CET 2006
On Sun March 5 2006 09:14, Rohnny Stormo wrote:
> Looking for a solution to select records from a choosen year.
> Would be perfect if the same sql works for postgres and
> sqlite3 In MsSql it would be done like this.
> SELECT id, dato FROM mytable WHERE year(dato)=2006
Date functions aren't part of the SQL specification, as far as I
know, and Sqlite has a much more minimal syntax than traditional
database servers. Any way you slice it, you're gonna have to do
something like
SELECT id, dato FROM mytable WHERE strftime('%Y',dato) = '2006'
for Sqlite, while
SELECT id, dato FROM mytable WHERE year(dato)=2006
should work with MySQL.
Rob
More information about the User
mailing list