473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calendar Date Question:

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.T oShortDateString());
Can someone tell me how i can add and subtract 30 days from it?

Thanks

Manny
Nov 18 '05 #1
2 911
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" <Ma*********@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
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.T oShortDateString());
Can someone tell me how i can add and subtract 30 days from it?

Thanks

Manny


Nov 18 '05 #2
thanks

"Ken Cox [Microsoft MVP]" wrote:
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" <Ma*********@discussions.microsoft.com> wrote in message
news:E2**********************************@microsof t.com...
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.T oShortDateString());
Can someone tell me how i can add and subtract 30 days from it?

Thanks

Manny


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cg_news | last post by:
In short, what I am trying to do is, based on a date, calculate the week of year (as described in ISO 8601), then calculate the first and last date in this week period and return them in the format...
0
by: Tim Graichen | last post by:
Hello, I am making use of the Active X calendar control (mscal.Calendar.7) in several places in my main form, with the following code Below is an example of the code I'm using for the...
8
by: Shyguy | last post by:
Is it possible to create a calendar that shows previous input data and also allows for input of new data?
3
by: Peter | last post by:
Is there anyway to make the System.Web.UI.WebControls.Calendar to display only Month Name and Year, like: January, 2006 February, 2006 ..... .... .... ....
2
by: DeanL | last post by:
I've been using calendar controls in a database used for recording incoming mail but one thing I'm not sure of is how to have the calendar control open with the date set at the current month/date. ...
3
by: thorpk | last post by:
I posted this problem earlier in the month and some one decided it was better to change the subject and ask a completely different question. I am therefore reposting. I am hoping some one can...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
0
by: abhishekbrave | last post by:
Hi, I have to reuse the code given below for displaying a calendar according to the month and year specified by user ...currently this code is fetching systme date and genrating calendar for that......
4
by: gubbachchi | last post by:
Hi all, Please anybody help me solve this problem. I am stuck up with this from past 2 weeks. I am developing an application where, when the user selects date from javascript datepicker and enters...
8
by: Arhaus | last post by:
I was wondering if someone could help me out. I am new to jscript and I need to modify a calendar onclick event. We have a calendar which displays the dates either in green or red based upon data...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.