From: Daevid Vincent Date: September 13 2006 12:57am Subject: RE: Getting next Birthdays List-Archive: http://lists.mysql.com/mysql/201821 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Read the comments at the bottom. D=C6VID =20 > -----Original Message----- > From: ESV Media GmbH [mailto:mysql_list@stripped]=20 > Sent: Wednesday, September 06, 2006 8:05 AM > To: mysql@stripped > Subject: Getting next Birthdays >=20 > Hello MySQL-User, >=20 > i need your help with the following query. > I want to get the next birthdays of my friends, but not only=20 > the one of=20 > this year. > So when im in december ( or november ) i want to see the birthdays of=20 > next year too.... > With my query i only see the birthdays of this year : >=20 > SELECT SQL_CACHE DISTINCT fname,lname, mem.mem_id AS p_id,=20 > DATE_FORMAT(mem.birthday,'%d.%m') AS geburtstag, > DATEDIFF(DATE_FORMAT(mem.birthday,CONCAT(DATE_FORMAT(NOW(),'%Y > '),'-%m-%d')),DATE_FORMAT(NOW(),'%Y-%m-%d'))=20 > as tage > FROM members mem > INNER JOIN network n ON ( ( n.mid =3D 1 AND n.action =3D 1 AND=20 > n.bid=3Dmem.mem_id ) OR ( n.bid =3D 1 AND n.action =3D 1 AND=20 > n.mid=3Dmem.mem_id) ) > WHERE DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d'),INTERVAL 1 DAY) <=3D=20 > DATE_FORMAT(mem.birthday,CONCAT(DATE_FORMAT(NOW(),'%Y'),'-%m-%d')) > ORDER BY tage >=20 > Thx a lot !!! >=20 > Cheers >=20 > Marco >=20 > spacemarc schrieb: > > 2006/9/6, Miles Thompson : > >> First of all - please reply to the list .. > >> > >> I thought you wanted all fields, that's the way your=20 > SELECT statement is > >> constructed. If just the first 20 char from fieldA, then ... > >> SELECT LEFT(fieldA, 20) AS fieldA FROM Tab1 > >> should do what you want. Again, check the syntax for LEFT() in the=20 > >> MySQL docs. > > > > the syntax is valid: > > from http://dev.mysql.com/doc/refman/5.0/en/string-functions.html: > > "LEFT(str,len) returns the leftmost len characters from the string > > str, or NULL if any argument is NULL." > > mysql> SELECT LEFT('foobarbar', 5); > > -> 'fooba' > > > > I have 30 fields: instead writing all 30 fields, I would want to > > select them all with * and only for one of they, fieldA, to=20 > obtain the > > first 20 chars: it's possible? > > > > >=20 >=20 >=20 > --=20 > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: =20 > http://lists.mysql.com/mysql?unsub=3Ddaevid@stripped >=20 >=20