Final Date will populate in tb.Text
I have textbox poplulates a number so that number 3
My thought would be
Code |
But it doesn't add 3 days to todays date
Any thoughts?
Code |
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Kirtan PatelRank #292 · 8.6K reputationPosted Mar 1, 2010, 2:38 PM EST
just replace last line of my above code to
textBox3.Text = date2.Add(ts).ToString("MMMM/dd/yyyy");
Bryian TanRank #396 · 6.3K reputationPosted Mar 1, 2010, 12:21 PM EST
Try something like DateTime.Now.AddDays(3).ToShortDateString()
Kirtan PatelRank #292 · 8.6K reputationPosted Mar 1, 2010, 1:00 PM EST
private void button1_Click(object sender, EventArgs e)
{
DateTime date1 = DateTime.Parse(textBox1.Text);
DateTime date2 = DateTime.Parse(textBox2.Text);
TimeSpan ts = date2.Subtract(date1);
textBox3.Text = date2.Add(ts).ToShortDateString();
}
RIck Mueller45 reputationPosted Mar 1, 2010, 2:32 PM EST
It works, but I'm having trouble formatting the date to ("MMMM/dd/yyyy")
Regards,
RIck Mueller45 reputationPosted Mar 1, 2010, 3:26 PM EST
I tried that, Didn't work
RIck Mueller45 reputationPosted Mar 1, 2010, 3:33 PM EST
It worked
Thanks