Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. display date in datagrid instead of date and time

display date in datagrid instead of date and time

Scheduled Pinned Locked Moved ASP.NET
help
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Saravanainit_2004 yahoo com
    wrote on last edited by
    #1

    i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem

    saravanan

    R N L K 4 Replies Last reply
    0
    • S Saravanainit_2004 yahoo com

      i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem

      saravanan

      R Offline
      R Offline
      RichardGrimmer
      wrote on last edited by
      #2

      use the ToShortDateString() method...

      DateTime dt = new DateTime();
      string str = dt.ToShortDateString();

      "Now I guess I'll sit back and watch people misinterpret what I just said......" Christian Graus At The Soapbox

      1 Reply Last reply
      0
      • S Saravanainit_2004 yahoo com

        i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem

        saravanan

        N Offline
        N Offline
        nirmalamari
        wrote on last edited by
        #3

        if you are pulling the data from database, try to do the date formating in sql server like CONVERT(VARCHAR,column name,101)

        1 Reply Last reply
        0
        • S Saravanainit_2004 yahoo com

          i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem

          saravanan

          L Offline
          L Offline
          Laxman Auti
          wrote on last edited by
          #4

          Saravanainit_2004@yahoo.com wrote:

          display date in datagrid instead of date and time

          1. Use formatter for DateTime fields. 2. mydate.ToString("dd/mm/yyyy"), mytime.ToString("hh:mm tt") mydate and mytime are variables of DateTime. Use the TemplateField for DateTime fields in GridView and override RowDateBound method of GridView and use the FindControl to find the label in GridViewRow.Assign the formated date to that label. That's it. :) Knock out 't' from can't, You can if you think you can :cool:

          1 Reply Last reply
          0
          • S Saravanainit_2004 yahoo com

            i want to display date in a datagrid column. To fill that datagrid i am filling data to a dataset and i am assigning that data set to datagrid.what my problem is that i am not able to display only date in that column.the time also is displaying with date.if i want to display time only then date also is coming along with time. please help me to solve this problem

            saravanan

            K Offline
            K Offline
            kubben
            wrote on last edited by
            #5

            Try: <%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "YourDateTimeFieldHere")).ToString("MM/dd/yyyy") #> Hope that helps. Ben -- modified at 21:10 Thursday 22nd March, 2007

            S 1 Reply Last reply
            0
            • K kubben

              Try: <%# Convert.ToDateTime(DataBinder.Eval(Container.DataItem, "YourDateTimeFieldHere")).ToString("MM/dd/yyyy") #> Hope that helps. Ben -- modified at 21:10 Thursday 22nd March, 2007

              S Offline
              S Offline
              siddisagar
              wrote on last edited by
              #6

              Goto Prpoerty Builder and Use {d:0} in DataFormatting String.. :laugh:

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups