Check upcoming B'day in Asp.net

Here is code to check upcoming b'day for next 7 days.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //DateTime dob = DateTime.Now.AddDays(8).AddYears(-18);
        DateTime dob = Convert.ToDateTime("5/20/1995");
        int years = DateTime.Now.Year - dob.Year;
        dob= dob.AddYears(years);
        DateTime check = DateTime.Now.AddDays(7);
        if ((dob > DateTime.Now) && (dob < check))
        {
            Response.Write("This week is your b'day!!!");
        }
    }
}

You can run this programmer on Monday to check b'day of the weeks.


Ebook Download
View all
Learn
View all