Current Month Facebook Friends Birthdays in Android

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 15:33:11

What you can do is calculate the following values using language you are using and use them in your FQL:

1st's day of the current month (17),
Today's month of the year (01)
End date day of the current month (31)

Make sure days and months are formatted using dd and MM respectively (padded with zero in case of single digits). Then your FQL would look like this:

SELECT name, birthday_date
  FROM user 
  WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
  AND strlen(birthday_date) != 0
  AND (
       substr(birthday_date, 0, 2) = '01'
       AND substr(birthday_date, 3, 5) >= '01'
       AND substr(birthday_date, 3, 5) < '31'
  ) 
  ORDER BY birthday_date

This will then return the friends who's birthday falls between 01 Jan and 31 Jan.

Update: Calculate current month and last date of current month:

Calendar cal=Calendar.getInstance();
int currentmonth=cal.get(Calendar.MONTH)+1

public static Date getLastDateOfMonth(int year, int month) {
   Calendar calendar = new GregorianCalendar(year, month, Calendar.DAY_OF_MONTH);
   calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
   return calendar.getTime();
}

Use this query to get the current months facebook friend in ascending order..

SELECT name, birthday, uid, pic_square FROM user WHERE uid in (SELECT uid2 FROM friend WHERE uid1=me())AND birthday_date >= '01/01/2013' AND birthday_date <= '31/01/2013' ORDER BY birthday_date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!