Turki
Turki

Reputation:

How can I get a date after 10 days ? in asp.net

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?

Upvotes: 2

Views: 6370

Answers (4)

RSolberg
RSolberg

Reputation: 26972

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)

Upvotes: 7

Lucas
Lucas

Reputation: 17434

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.

Upvotes: 0

Syed Tayyab Ali
Syed Tayyab Ali

Reputation: 3681

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)

Upvotes: 0

Guffa
Guffa

Reputation: 700592

Dim next10days As Date = Date.Now.AddDays(10)

Upvotes: 22

Related Questions