Date Format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pawanez4u
    New Member
    • Sep 2007
    • 10

    Date Format

    Hi Every one,

    I am working on ASP (C#) i got struk up with the following problem.

    I am using the standard calendar control to get the date. I am able to display the selected date in this format "DD-MMM-YYYY HH:MM:SS". I want the selected date should in "dd/mm/yy" format.

    Kindly help me..

    Thanks in advance

    Pavankumar. P
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Is there a .ToString() on the object anywhere? (Might be implicitly used)

    But consider:
    Code:
    DateTime dt=DateTime.Now;
    string mydatestring= dt.ToString( "dd/MM/yy");

    Comment

    • pawanez4u
      New Member
      • Sep 2007
      • 10

      #3
      Originally posted by Plater
      Is there a .ToString() on the object anywhere? (Might be implicitly used)

      But consider:
      Code:
      DateTime dt=DateTime.Now;
      string mydatestring= dt.ToString( "dd/MM/yy");

      hi Sir,

      Thanks for the needful. But this shows the current date and time.I want the date which is selected from the calendar control of asp?

      Regards
      Pavan

      Comment

      • baburk
        New Member
        • Oct 2006
        • 111

        #4
        Hi

        Give it like this.
        TextBox1.Text = Calendar1.Selec tedDate.ToShort DateString();

        You get date in the format of mm/dd/yyyy

        Comment

        • baburk
          New Member
          • Oct 2006
          • 111

          #5
          To get the date in more formates give it like this

          TextBox1.Text = Calendar1.Selec tedDate.GetDate TimeFormats('d' )[6];

          The dimension take 0-6 ie. 7 Formats available

          Try it

          Bye..

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Originally posted by pawanez4u
            hi Sir,

            Thanks for the needful. But this shows the current date and time.I want the date which is selected from the calendar control of asp?

            Regards
            Pavan
            It was just an example, the hope was that you would decipher the two simple lines of code.

            Code:
            DateTime dt=<whatever date the calender picker is using>
            string mydatestring= dt.ToString( "dd/MM/yy");

            Comment

            Working...