Calendar Date Question:

Discussion in 'ASP .Net' started by =?Utf-8?B?TWFubnkgQ2hvaGFu?=, Nov 8, 2004.

  1. 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
    =?Utf-8?B?TWFubnkgQ2hvaGFu?=, Nov 8, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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
    Ken Cox [Microsoft MVP], Nov 9, 2004
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > > 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

    >
    >
    =?Utf-8?B?TWFubnkgQ2hvaGFu?=, Nov 9, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    1
    Views:
    563
    Matthew Speed
    Nov 8, 2003
  2. Shevek
    Replies:
    3
    Views:
    6,000
    Shevek
    Jun 23, 2004
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,177
    Michael Borgwardt
    May 30, 2004
  4. Shevek
    Replies:
    0
    Views:
    369
    Shevek
    Jun 23, 2004
  5. Replies:
    0
    Views:
    187
Loading...

Share This Page