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. General Programming
  3. C#
  4. Ok simple problem

Ok simple problem

Scheduled Pinned Locked Moved C#
csharphtmlasp-netdatabasehelp
7 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.
  • M Offline
    M Offline
    Michael101
    wrote on last edited by
    #1

    This is a simple problem that I cannot believe that I can't solve!! I have a C# ASP.NET site.... Easy! In my HTML/ASP I have a datagrid declared and one of the columns in my datagrid pulls dates from the database (through a data set) and displays them on the page. My dates come up looking like this: 21/02/2006 12:00:00 AM I want them to look like this: 21/02/06 I've tried to do this to the header DataFormatString="{0:dd/MM/yy}" but that doesn't work! Any suggestions to this problem would be awesomely appreciated!! Cheers everyone, Michael!!

    A P S 3 Replies Last reply
    0
    • M Michael101

      This is a simple problem that I cannot believe that I can't solve!! I have a C# ASP.NET site.... Easy! In my HTML/ASP I have a datagrid declared and one of the columns in my datagrid pulls dates from the database (through a data set) and displays them on the page. My dates come up looking like this: 21/02/2006 12:00:00 AM I want them to look like this: 21/02/06 I've tried to do this to the header DataFormatString="{0:dd/MM/yy}" but that doesn't work! Any suggestions to this problem would be awesomely appreciated!! Cheers everyone, Michael!!

      A Offline
      A Offline
      Arun Immanuel
      wrote on last edited by
      #2

      Why can't you query that format from the database itself? set dateformat 'dmy' select convert( varchar,cast(floor(cast(cast(dateColumn as datetime)as float)) as datetime),103) "Date" Hope that helps you.

      Regards, Arun Kumar.A

      M 1 Reply Last reply
      0
      • A Arun Immanuel

        Why can't you query that format from the database itself? set dateformat 'dmy' select convert( varchar,cast(floor(cast(cast(dateColumn as datetime)as float)) as datetime),103) "Date" Hope that helps you.

        Regards, Arun Kumar.A

        M Offline
        M Offline
        Michael101
        wrote on last edited by
        #3

        Cheers for that.... that did the job!! Thanks so much for you help Arun

        M 1 Reply Last reply
        0
        • M Michael101

          This is a simple problem that I cannot believe that I can't solve!! I have a C# ASP.NET site.... Easy! In my HTML/ASP I have a datagrid declared and one of the columns in my datagrid pulls dates from the database (through a data set) and displays them on the page. My dates come up looking like this: 21/02/2006 12:00:00 AM I want them to look like this: 21/02/06 I've tried to do this to the header DataFormatString="{0:dd/MM/yy}" but that doesn't work! Any suggestions to this problem would be awesomely appreciated!! Cheers everyone, Michael!!

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          Please use yyyy-MM-dd, or it possible to allow the user's browser/OS to determine which format the user wants?

          V 1 Reply Last reply
          0
          • M Michael101

            Cheers for that.... that did the job!! Thanks so much for you help Arun

            M Offline
            M Offline
            Muammar
            wrote on last edited by
            #5

            If someone answered your question, you should vote for that for two main reasons: 1. To help others to recognize the right answer post that worked well 2. To help the one who helped you on his way up to be an MVP here, which's the only way to say thank you here in cp;) Please do vote. Cheers.


            Smile: A curve that can set a lot of things straight! (\ /) (O.o) (><)

            1 Reply Last reply
            0
            • P PIEBALDconsult

              Please use yyyy-MM-dd, or it possible to allow the user's browser/OS to determine which format the user wants?

              V Offline
              V Offline
              Vikram A Punathambekar
              wrote on last edited by
              #6

              Well said. I can't believe the pompousness and insensitivity of the jerks who display dates as MM/dd/yyyy. I find it incredibly irritating and threw out Sunbird because of that. Too bad I can't throw out the corporate apps.

              Cheers, Vıkram.


              Déjà moo - The feeling that you've seen this bull before. Join the CP group at NationStates. Password: byalmightybob

              1 Reply Last reply
              0
              • M Michael101

                This is a simple problem that I cannot believe that I can't solve!! I have a C# ASP.NET site.... Easy! In my HTML/ASP I have a datagrid declared and one of the columns in my datagrid pulls dates from the database (through a data set) and displays them on the page. My dates come up looking like this: 21/02/2006 12:00:00 AM I want them to look like this: 21/02/06 I've tried to do this to the header DataFormatString="{0:dd/MM/yy}" but that doesn't work! Any suggestions to this problem would be awesomely appreciated!! Cheers everyone, Michael!!

                S Offline
                S Offline
                soneliso
                wrote on last edited by
                #7

                try ToShortDateString()

                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