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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Date

Date

Scheduled Pinned Locked Moved ASP.NET
cssdatabasewpfwcfquestion
8 Posts 4 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
    jonhbt
    wrote on last edited by
    #1

    I have a field in the database which is of type date time. When i return it in a grid view I want to remove the time and show only the date. Is it possible to show only the date? Thank you. PS I am showing the date by binding the grid view.

    P 1 Reply Last reply
    0
    • J jonhbt

      I have a field in the database which is of type date time. When i return it in a grid view I want to remove the time and show only the date. Is it possible to show only the date? Thank you. PS I am showing the date by binding the grid view.

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      The MSDN documentation has an article[^] on date/time format strings.

      Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

      B 1 Reply Last reply
      0
      • P pmarfleet

        The MSDN documentation has an article[^] on date/time format strings.

        Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

        B Offline
        B Offline
        biswa47
        wrote on last edited by
        #3

        Ofcourse its possible, use substring() in sql. bofore dispaly data in the grid use substring in db

        H P 2 Replies Last reply
        0
        • B biswa47

          Ofcourse its possible, use substring() in sql. bofore dispaly data in the grid use substring in db

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          You can do a Convert(varchar, dateTime field, 105) for instance. More information: here[^]

          P 1 Reply Last reply
          0
          • B biswa47

            Ofcourse its possible, use substring() in sql. bofore dispaly data in the grid use substring in db

            P Offline
            P Offline
            pmarfleet
            wrote on last edited by
            #5

            biswa47 wrote:

            use substring() in sql. bofore dispaly data in the grid use substring in db

            This isn't the right way to do it. The .NET Framework has support for formatting dates in different ways. See the link I provided in my original reply.

            1 Reply Last reply
            0
            • H Herman T Instance

              You can do a Convert(varchar, dateTime field, 105) for instance. More information: here[^]

              P Offline
              P Offline
              pmarfleet
              wrote on last edited by
              #6

              digimanus wrote:

              You can do a Convert(varchar, dateTime field, 105) for instance.

              Date formatting should be done in the presentation layer. The .NET Framework provides built-in support for this. See the link in my original reply.

              H 1 Reply Last reply
              0
              • P pmarfleet

                digimanus wrote:

                You can do a Convert(varchar, dateTime field, 105) for instance.

                Date formatting should be done in the presentation layer. The .NET Framework provides built-in support for this. See the link in my original reply.

                H Offline
                H Offline
                Herman T Instance
                wrote on last edited by
                #7

                I think it CAN be done in .NET Let the poster of this problem decide what he wants to. things like: DateTime dateValue = DateTime.Now String whatTime = String.Format("{0:yyyyMMdd}", dateValue); can also be done.

                P 1 Reply Last reply
                0
                • H Herman T Instance

                  I think it CAN be done in .NET Let the poster of this problem decide what he wants to. things like: DateTime dateValue = DateTime.Now String whatTime = String.Format("{0:yyyyMMdd}", dateValue); can also be done.

                  P Offline
                  P Offline
                  pmarfleet
                  wrote on last edited by
                  #8

                  digimanus wrote:

                  Let the poster of this problem decide what he wants to.

                  This forum is a place for people to discuss solutions to problems. If I want to critisize other people's suggestions, I will do. I certainly don't need your permission. The basic fact of the matter is that using the T-SQL SUBSTRING is a clumsy way to format dates. If T-SQL must be used, the CONVERT function is better. IMHO, .NET provides a much richer API for data presentation and should be the tool of choice.

                  Paul Marfleet "No, his mind is not for rent To any God or government" Tom Sawyer - Rush

                  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