tags:

views:

714

answers:

4

Hello,

This code returns today's date:

  Dim next10days As Date = Date.Now

But how can I get the date for the 10th day from today?

+21  A: 
Dim next10days As Date = Date.Now.AddDays(10)
Guffa
Thanks..really thanks!
Oh *that* kind of date ;-)
Austin Salonen
A: 

msdn reference

    ' Calculate what day of the week is 10 days from this instant.
Dim today As System.DateTime
Dim answer As System.DateTime

today = System.DateTime.Now
answer = today.AddDays(10)

System.Console.WriteLine("{0:dddd}", answer)
Syed Tayyab Ali
+6  A: 

1. If you were to simply return the value:

//C#
return DateTime.Now.AddDays(10);

//VB
Return Date.Now.AddDays(10)

2. If you really just want a variable you can work with:

//C#
var MyDate10DaysFromNow = DateTime.Now.AddDays(10);

//VB
Dim MyDate10DaysFromNow as Date = Date.Now.AddDays(10)
RSolberg
you are so lame... :) +1
jlembke
I thought about adding the sample in perl too.
RSolberg
A: 
Dim next10days As Date = Date.Now.AddDays(10)

Although, technically, it should be Date.Today, not Date.Now, because Now also includes the time and you only want a date.

Lucas
wow three answes and 18 upvote in the time i wrote this! (ok, i was reading other questions, too)
Lucas