get date

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    get date

    If I have a date such as 4/2/2008, is there a way to go back a month such as
    3/2/2008?



  • Hans Kesting

    #2
    Re: get date

    Mike explained :
    If I have a date such as 4/2/2008, is there a way to go back a month such as
    3/2/2008?
    DateTime dt = new DateTime(2008,4 ,2);
    dt = dt.AddMonth(-1);


    Hans Kesting


    Comment

    • =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=

      #3
      RE: get date

      DateTime myDate = DateTime.Parse( "4/2/2008");
      DateTime olderDate = myDate.AddMonth s(-1);
      -- Peter
      Site: http://www.eggheadcafe.com
      UnBlog: http://petesbloggerama.blogspot.com
      Short Urls & more: http://ittyurl.net


      "Mike" wrote:
      If I have a date such as 4/2/2008, is there a way to go back a month such as
      3/2/2008?
      >
      >
      >
      >

      Comment

      • Mike

        #4
        Re: get date

        I've tried it and it gives me this error when I try to compile it:


        DateTime dt = new DateTime(2008,4 ,2);
        dt = dt.AddMonth(-1);

        Error 24 'System.DateTim e' does not contain a definition for 'AddMonth'

        "Hans Kesting" <invalid.hansdk @spamgourmet.co mwrote in message
        news:mn.13797d8 47e488316.82533 @spamgourmet.co m...
        Mike explained :
        >If I have a date such as 4/2/2008, is there a way to go back a month such
        >as 3/2/2008?
        >
        DateTime dt = new DateTime(2008,4 ,2);
        dt = dt.AddMonth(-1);
        >
        >
        Hans Kesting
        >
        >

        Comment

        • Mike

          #5
          Re: get date

          I got it, its dt.AddMonths(-1);


          "Hans Kesting" <invalid.hansdk @spamgourmet.co mwrote in message
          news:mn.13797d8 47e488316.82533 @spamgourmet.co m...
          Mike explained :
          >If I have a date such as 4/2/2008, is there a way to go back a month such
          >as 3/2/2008?
          >
          DateTime dt = new DateTime(2008,4 ,2);
          dt = dt.AddMonth(-1);
          >
          >
          Hans Kesting
          >
          >

          Comment

          Working...