Search

Friday, April 18, 2014
0 comments

Add days in existing date ASP.NET example

8:38 AMFriday, April 18, 2014

Introduction

Using AddDays method  you can add Days in integer, Object will be updated with new date. This method is used where you want to calculate date after some days. Like Library management project. Lets take an simple example
<form id="form1" runat="server">
    <div>  
        <asp:Button ID="Button1"
        runat="server"
        BackColor="#66CCFF"
        onclick="Button1_Click" Text="Click" />  
    </div>
        <asp:Label ID="Label1"
        runat="server"
        BackColor="Yellow"></asp:Label>
    </form>
Code Behind-
protected void Button1_Click(object sender, EventArgs e)
        {          
            DateTime today = DateTime.Today;
            DateTime after2Days = today.AddDays(2);
            Label1.Text = "today= " + today.ToLongDateString();
            Label1.Text += "<br /><br />after added 2 days with today= ";
            Label1.Text += after2Days.ToLongDateString();

        }  
OutPut-


Add days in existing date ASP.NET example

Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top