I want to show list of people whose birthdays are in coming 15 days. I have below dates in my table column:
LET ME MORE CLEAR MY QUESTION
BELOW IS MY EMPLOYEE TABLE COLUMNS
EMP_ID |EMP_TYPE |EMP_USERNAME |EMP_DOB ======= |========== |=============== |================== 1 |ADMIN |ELENA GILBERT |1993-02-19 2 |EMPLOYEE |KATHERINE PIERCE |1993-03-19 3 |EMPLOYEE |STEFAN SALVATORE |1993-04-19 4 |EMPLOYEE |DAMON SALVATORE |1993-05-19 5 |EMPLOYEE |JEREMY GILBERT |1993-05-20
Now I just want to show upcoming birthdays in 15 days. Below I created a custom class in which I set two properties:
public class Birthday
{
public string Name { get; set; }
public DateTime date { get; set; }
}
Below is my web method which return me a list from which I want just Emp_Username and Emp_DOB which upcoming within 15 days.
[WebMethod]
public static List<Birthday> getBirthday()
{
var slist = new List<Birthday>();
var db = new BLUEPUMPKINEntities();
var query = (from emp in db.Employees
let BirthdayDiff = (new DateTime(DateTime.Now.Year,
emp.EMP_DOB.Value.Month, emp.EMP_DOB.Value.Day) - DateTime.Now).TotalDays where BirthdayDiff >= 0 && BirthdayDiff <= 15
select new Birthday { Name = emp.EMP_USERNAME, date = Convert.ToDateTime(emp.EMP_DOB) });
return slist.ToList();
}
Problem is my above code is not working and not showing any errors in de-bugging.