How do I format DateTime as mmddyyyy

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

    How do I format DateTime as mmddyyyy

    I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
    is the easiest way to do this?


  • Jack

    #2
    Re: How do I format DateTime as mmddyyyy

    Never mind... found the pattern ("MMddyyyy") .

    (I was using "mmddyyyy")


    Comment

    • Rakesh Rajan

      #3
      RE: How do I format DateTime as mmddyyyy

      Use the ToString overload and pass the format required in it.

      Eg:
      dt.ToString("mm ddyyyy"); or
      dt.ToString("dd-mm-yy");
      --
      Rakesh Rajan


      "Jack" wrote:
      [color=blue]
      > I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
      > is the easiest way to do this?
      >
      >
      >[/color]

      Comment

      • Jack

        #4
        Re: How do I format DateTime as mmddyyyy

        That is what I was attempting but found a nuance... mmddyyyy formats as
        minute, day, month. The correct format is MMddyyyy.

        "Rakesh Rajan" <RakeshRajan@di scussions.micro soft.com> wrote in message
        news:89EA38AD-B72B-4364-9EF7-2F5943616EB9@mi crosoft.com...[color=blue]
        > Use the ToString overload and pass the format required in it.
        >
        > Eg:
        > dt.ToString("mm ddyyyy"); or
        > dt.ToString("dd-mm-yy");
        > --
        > Rakesh Rajan
        >
        >
        > "Jack" wrote:
        >[color=green]
        > > I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy.[/color][/color]
        What[color=blue][color=green]
        > > is the easiest way to do this?
        > >
        > >
        > >[/color][/color]


        Comment

        • anon

          #5
          Re: How do I format DateTime as mmddyyyy

          Jack wrote:[color=blue]
          > I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
          > is the easiest way to do this?
          >
          >[/color]
          DateTime dt = DateTime.Now;

          System.Console. WriteLine(strin g.Format("{0,2: 00}{1,2:00}{2,0 4:0000}",dt.Day ,dt.Month,dt.Ye ar));

          Comment

          • Jonathan Stowe

            #6
            Re: How do I format DateTime as mmddyyyy

            anon <a@a.com> wrote:[color=blue]
            > Jack wrote:[color=green]
            >> I am trying to format a DateTime object as mmddyyyy and NOT mm/dd/yyyy. What
            >> is the easiest way to do this?
            >>
            >>[/color]
            > DateTime dt = DateTime.Now;
            >
            > System.Console. WriteLine(strin g.Format("{0,2: 00}{1,2:00}{2,0 4:0000}",dt.Day ,dt.Month,dt.Ye ar));[/color]

            or alternatvely:

            dt.ToString("MM ddyyyy");

            /J\

            Comment

            Working...