Current Month Facebook Friends Birthdays in Android

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();
}

Leave a Comment