i m finding user according to age, but in database i have only date of birth, my dob in database is date type.stores values like 1990-08-22,
in need to find users from age 18 to age 25
var year = DateTime.Now.Year; var month = DateTime.Now.Month; var day = DateTime.Now.Day; string dob1= dobyear1 + "-" + month + "-" + day; DateTime dob21 = Convert.ToDateTime(dob1); var dobyear2 = year - 25; string dob2 = dobyear2 + "-" + month + "-" + 1; DateTime dob22 = Convert.ToDateTime(dob2); var userslist = db.Users.Where(s => s.Gender == "Female" && s.DOB <= dob21 && s.DOB >= dob22).ToList();
It's working
© COPYRIGHT 2024 ASPSnippets.com ALL RIGHTS RESERVED.