how to calculate the date by using integer variable which can know the lasted date
for example

user key in date is 2/20/2008
and he want know the after intvariable day is which date
like this user key in date is 2/20/2008 - intvariable = date user require date
dim keyindate as date
dim intvarible as int
assume intvarible is 19
the intariable data type must be integer because this data need processes by another
2/20/2008 - 19 = 2/1/2008
the 2/1/2008 i need to get

thanks

Recommended Answers

All 4 Replies

I create a demo for you creating a new web site with default.aspx, the markup(aspx) and code behind is as follows :

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Subtract" />
DateTime myDate = Convert.ToDateTime(TextBox1.Text);
        double subt = Convert.ToDouble(TextBox2.Text);
        DateTime newDate = myDate.AddDays(-subt);
        Response.Write(newDate.ToShortDateString());

thanks for reply.This is C# format?Can you write the vb.net format for show me because me only know vb.net
thanks

thanks for reply.This is C# format?Can you write the vb.net format for show me because me only know vb.net
thanks

Dim myDate As DateTime = Convert.ToDateTime(TextBox1.Text)
Dim subt As Double = Convert.ToDouble(TextBox2.Text)
Dim newDate As DateTime = myDate.AddDays(-subt)
Response.Write(newDate.ToShortDateString())

Yup, I would just do that as well:

Dim myDate As DateTime = Trim(TextBox1.Text)
Dim newDate As String = myDate.AddDays(-(intvariable))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.