0

How to get Facebook Friends Birthdays in order of upcoming like: show top on list those birthdays are coming next by using current date and so on.

still i am getting birthdays in form of January to December, Getting Friends on Top those birthdays in January and on bottom those birthdays in December.

and i am also getting friends on top those birthdays has gone in January like birthday was on 2nd Jan or 28 Jan,

Now i just want to see list of Next Upcoming Birthdays,those passed away on bottom of the list...

Like here:

https://itunes.apple.com/in/app/birthday-sweet-birthday-calendar/id367346406?mt=8

https://play.google.com/store/apps/details?id=com.scoompa.birthdayreminder&hl=en

they have shown recents on top and later on bottom in a List...

Still i am using this query :

    String query = "select name, birthday, uid, pic_square from user where uid in (select uid2 from friend where uid1=me()) order by birthday_date";

Also Tried with this code:

 Calendar c = Calendar.getInstance(); 
    int month = c.get(Calendar.MONTH)+1;

    String query = "select name, birthday, uid, pic_square from user where uid in " +
    "(select uid2 from friend where uid1=me())AND birthday_date >= '" + month + "/01' AND birthday_date <= '" + month + "/31' ORDER BY birthday_date ASC";
Babu
  • 957
  • 1
  • 9
  • 21

1 Answers1

1

You can sort the list of friends according to their birthday. like,

SELECT uid, name, birthday_date FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=me())
AND birthday_date >= CURRENT_DATE
AND birthday_date <= LAST_DATE
ORDER BY birthday_date ASC

Here in place of CURRENT_DATE you could enter the current system date. So this will show the upcoming birthday from the current date. and in place of LAST_DATE, you could use the date upto which you want to show the upcoming birthdays.

Sahil Mahajan Mj
  • 11,033
  • 8
  • 53
  • 100
  • buddy i have tried with this: Calendar c = Calendar.getInstance(); int month = c.get(Calendar.MONTH)+1; String query = "select name, birthday, uid, pic_square from user where uid in " + "(select uid2 from friend where uid1=me())AND birthday_date >= '" + month + "/01' AND birthday_date <= '" + month + "/31' ORDER BY birthday_date ASC"; but not getting any list... – Babu Jan 31 '13 at 11:40
  • So, what you are getting in the **month** variable.? Is it **2(February)**.? Do you know february doesnt have any **31 Date**.? Are you sure, you have some friends whose birthday falls in between **1 February** to the date you have used.? – Sahil Mahajan Mj Jan 31 '13 at 11:46
  • i am not getting list of friends even, please tell me what i should write and where i am doing mistake need help buddy.. – Babu Jan 31 '13 at 11:49
  • @Rakesh, Dont panic, first check that what value you are getting in the **month** variable. try printing some **Log** to check its value. – Sahil Mahajan Mj Jan 31 '13 at 11:50
  • thanks again for fast reply, ok buddy i will try that and then get back to you, for now thanks again... – Babu Jan 31 '13 at 11:53