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. DataGrid DATE process???

DataGrid DATE process???

Scheduled Pinned Locked Moved ASP.NET
csharphelpasp-netdatabasesql-server
8 Posts 2 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.
  • J Offline
    J Offline
    John Sundar
    wrote on last edited by
    #1

    hai, i m using ASP.NET with C# (.net 2005, 2.0 framework) here i have a datagrid which contains 10 columns. the 4,5,8 column contains date in the format (7/23/2007 12:00:00 AM). i want to change those date in (23-Jul-2007). the major key point in this is.... 1. Fields are dynamic, so i cant fix in DATABOUNDCOLUMN 2. The placement should be the same (i.e, 4,5,8 columns) 3. The data are filled to datagrid from SQL Server. How to achieve it? help me...... - KARAN

    S 1 Reply Last reply
    0
    • J John Sundar

      hai, i m using ASP.NET with C# (.net 2005, 2.0 framework) here i have a datagrid which contains 10 columns. the 4,5,8 column contains date in the format (7/23/2007 12:00:00 AM). i want to change those date in (23-Jul-2007). the major key point in this is.... 1. Fields are dynamic, so i cant fix in DATABOUNDCOLUMN 2. The placement should be the same (i.e, 4,5,8 columns) 3. The data are filled to datagrid from SQL Server. How to achieve it? help me...... - KARAN

      S Offline
      S Offline
      Sandeep Kumar
      wrote on last edited by
      #2

      Hi can acheive that in two ways.

      John Sundar wrote:

      i want to change those date in (23-Jul-2007).

      1. while writing query to retriew data from SQL server you need to use convert function. eg: select convert(varchar,DateColumn,105) from tablename 2) In databound of datagrid coloum u can foramt.

      Regards, Sandeep Kumar.V

      J 1 Reply Last reply
      0
      • S Sandeep Kumar

        Hi can acheive that in two ways.

        John Sundar wrote:

        i want to change those date in (23-Jul-2007).

        1. while writing query to retriew data from SQL server you need to use convert function. eg: select convert(varchar,DateColumn,105) from tablename 2) In databound of datagrid coloum u can foramt.

        Regards, Sandeep Kumar.V

        J Offline
        J Offline
        John Sundar
        wrote on last edited by
        #3

        Thanks sandeep kumar.V but the thing i need is "DD-MMM-YYYY" (this exact format). and also i need the alias name also... my exact query..... select convert(varchar,column1 as "Test column",106) from tbl_name how to achieve it?????

        S 1 Reply Last reply
        0
        • J John Sundar

          Thanks sandeep kumar.V but the thing i need is "DD-MMM-YYYY" (this exact format). and also i need the alias name also... my exact query..... select convert(varchar,column1 as "Test column",106) from tbl_name how to achieve it?????

          S Offline
          S Offline
          Sandeep Kumar
          wrote on last edited by
          #4

          John Sundar wrote:

          select convert(varchar,column1 as "Test column",106) from tbl_name

          the query is not correct..... select convert(varchar,column1,106) as "Test column" from tbl_name

          Regards, Sandeep Kumar.V

          J 1 Reply Last reply
          0
          • S Sandeep Kumar

            John Sundar wrote:

            select convert(varchar,column1 as "Test column",106) from tbl_name

            the query is not correct..... select convert(varchar,column1,106) as "Test column" from tbl_name

            Regards, Sandeep Kumar.V

            J Offline
            J Offline
            John Sundar
            wrote on last edited by
            #5

            Thanks a lot sandeep... i achieved 90% of my requirement. but i cant get the separator (any separator is OKAY) the output is "25 Jan 2007". my requirement is "25-Jan-2007". is there anyway to achieve it?, so that my requirement will get fulfilled 100% :)

            modified on Saturday, April 12, 2008 3:12 AM

            S 1 Reply Last reply
            0
            • J John Sundar

              Thanks a lot sandeep... i achieved 90% of my requirement. but i cant get the separator (any separator is OKAY) the output is "25 Jan 2007". my requirement is "25-Jan-2007". is there anyway to achieve it?, so that my requirement will get fulfilled 100% :)

              modified on Saturday, April 12, 2008 3:12 AM

              S Offline
              S Offline
              Sandeep Kumar
              wrote on last edited by
              #6

              Hi..... I think there is no formatter to format like that...... in dotnet you can acheive that.....like..... eg: <asp:BoundField **DataFormatString="{0:dd-MMM-yyyy}"** DataField="ShippedDate" HeaderText="Shipped Date" />

              Regards, Sandeep Kumar.V

              J 2 Replies Last reply
              0
              • S Sandeep Kumar

                Hi..... I think there is no formatter to format like that...... in dotnet you can acheive that.....like..... eg: <asp:BoundField **DataFormatString="{0:dd-MMM-yyyy}"** DataField="ShippedDate" HeaderText="Shipped Date" />

                Regards, Sandeep Kumar.V

                J Offline
                J Offline
                John Sundar
                wrote on last edited by
                #7

                Thanks a lot sandeep... nice to meet you......... :-O

                1 Reply Last reply
                0
                • S Sandeep Kumar

                  Hi..... I think there is no formatter to format like that...... in dotnet you can acheive that.....like..... eg: <asp:BoundField **DataFormatString="{0:dd-MMM-yyyy}"** DataField="ShippedDate" HeaderText="Shipped Date" />

                  Regards, Sandeep Kumar.V

                  J Offline
                  J Offline
                  John Sundar
                  wrote on last edited by
                  #8

                  I found the answer in query itself sandeep... just refer it SELECT REPLACE(CONVERT(VARCHAR, column_name, 106), ' ', '-') as "column 1" from tbl_name :) Take care...

                  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