Vijjendra
Vijjendra

Reputation: 25233

Find date after a given weeks(months) in ASP.NET

I want to find a date after a give weeks(months). For example, I want to find the date after 2 week from today or find the date after 4 month from today.

Thanks

Upvotes: 2

Views: 2482

Answers (3)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

do you want like ?

DateTime dt = DateTime.Now.AddDays(14);
DateTime dt1 = DateTime.Now.AddMonths(4);

Upvotes: 3

Dmytrii Nagirniak
Dmytrii Nagirniak

Reputation: 24108

Two weeks after today:

DateTime.Now.Date.AddDays(2*7)  

Four months after today:

DateTime.Now.Date.AddMonths(4)  

Use DateTime.Date if you want only the date without current time (as in the sample).

Upvotes: 2

pmarflee
pmarflee

Reputation: 3428

DateTime.Now.AddDays(14)

to get the date 2 weeks from now

or

DateTime.Now.AddMonths(4)

to get the date 4 months from now

NB: This has nothing to do with ASP.NET. DateTime is part of the .NET BCL.

Upvotes: 2

Related Questions