How to format datetime?

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

    #1

    How to format datetime?

    Hi,
    I 've ("9/27/2003 12:11:31 PM") this value in database .
    i need to get only this value ("9/27/2003 " ) .How will i format it to get
    this value?

    It will be helpful if some one could point me to some code sample for the
    same

    thank you in advance



  • Ravikanth[MVP]

    #2
    How to format datetime?

    Hi

    Construct new Datetime values from value in database
    DateTime dt = new DateTime(databa sevalue)
    then use dt.Date.

    HTH
    Ravikanth[MVP]

    [color=blue]
    >-----Original Message-----
    >Hi,
    >I 've ("9/27/2003 12:11:31 PM") this value in database .
    >i need to get only this value ("9/27/2003 " ) .How will[/color]
    i format it to get[color=blue]
    >this value?
    >
    >It will be helpful if some one could point me to some[/color]
    code sample for the[color=blue]
    >same
    >
    >thank you in advance
    >
    >
    >
    >.
    >[/color]

    Comment

    • Ignacio Machin

      #3
      Re: How to format datetime?

      Hi,

      Try DateTime.ToShor tDateString()

      Hope this help,

      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation

      "Vinitha" <vinitha_k@hotm ail.com> wrote in message
      news:eziNswohDH A.520@tk2msftng p13.phx.gbl...[color=blue]
      > Hi,
      > I 've ("9/27/2003 12:11:31 PM") this value in database .
      > i need to get only this value ("9/27/2003 " ) .How will i format it to[/color]
      get[color=blue]
      > this value?
      >
      > It will be helpful if some one could point me to some code sample for the
      > same
      >
      > thank you in advance
      >
      >
      >[/color]


      Comment

      • Ayca Aksu

        #4
        Re: How to format datetime?

        if you want string, you can use:

        DateTime aDateTime = getDateTimeFrom DB(some criteria);
        string str = aDateTime.Value .ToShortDateStr ing();

        "Vinitha" <vinitha_k@hotm ail.com> wrote in message
        news:eziNswohDH A.520@tk2msftng p13.phx.gbl...[color=blue]
        > Hi,
        > I 've ("9/27/2003 12:11:31 PM") this value in database .
        > i need to get only this value ("9/27/2003 " ) .How will i format it to[/color]
        get[color=blue]
        > this value?
        >
        > It will be helpful if some one could point me to some code sample for the
        > same
        >
        > thank you in advance
        >
        >
        >[/color]


        Comment

        • Hans Kesting

          #5
          Re: How to format datetime?


          "Vinitha" <vinitha_k@hotm ail.com> wrote in message
          news:eziNswohDH A.520@tk2msftng p13.phx.gbl...[color=blue]
          > Hi,
          > I 've ("9/27/2003 12:11:31 PM") this value in database .
          > i need to get only this value ("9/27/2003 " ) .How will i format it to[/color]
          get[color=blue]
          > this value?
          >
          > It will be helpful if some one could point me to some code sample for the
          > same
          >
          > thank you in advance
          >
          >
          >[/color]

          DateTime theDate .....
          theDate.ToStrin g("m/d/yyyy");

          if it is the string representation that you want.



          Comment

          Working...