Calendar Date Question:

G

Guest

Hey Guys, got a simple question: I am using C#

I am extracting date from the calendar control as follows.
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
Can someone tell me how i can add and subtract 30 days from it?

Thanks

Manny
 
K

Ken Cox [Microsoft MVP]

Hi Manny,

Just used AddDays. For previous days, use a negative integer.

Here's some sample code:

System.DateTime tempDate;
tempDate=Calendar2.TodaysDate;
tempDate=tempDate.AddDays(30);
Response.Write(tempDate.ToShortDateString() + "<br>");
tempDate=Calendar2.TodaysDate;
tempDate=tempDate.AddDays(-30);
Response.Write(tempDate.ToShortDateString() + "<br>");

Does this help?

Ken
Microsoft MVP [ASP.NET]
 
G

Guest

thanks

Ken Cox said:
Hi Manny,

Just used AddDays. For previous days, use a negative integer.

Here's some sample code:

System.DateTime tempDate;
tempDate=Calendar2.TodaysDate;
tempDate=tempDate.AddDays(30);
Response.Write(tempDate.ToShortDateString() + "<br>");
tempDate=Calendar2.TodaysDate;
tempDate=tempDate.AddDays(-30);
Response.Write(tempDate.ToShortDateString() + "<br>");

Does this help?

Ken
Microsoft MVP [ASP.NET]


Manny Chohan said:
Hey Guys, got a simple question: I am using C#

I am extracting date from the calendar control as follows.
tempDate=Convert.ToDateTime(Calendar2.TodaysDate.ToShortDateString());
Can someone tell me how i can add and subtract 30 days from it?

Thanks

Manny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top