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. .NET (Core and Framework)
  4. String was not recognized as a valid DateTime.

String was not recognized as a valid DateTime.

Scheduled Pinned Locked Moved .NET (Core and Framework)
com
21 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 Slacker007

    I would not use Convert.ToDateTime with a text/string input. Instead try using TryParse with datetime. DateTime.TryParse Method (String, DateTime) (System)[^]

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #9

    I don't think you would set a DateTime to string.empty.

    S 1 Reply Last reply
    0
    • L Lost User

      I don't think you would set a DateTime to string.empty.

      S Offline
      S Offline
      Slacker007
      wrote on last edited by
      #10

      Of course you can't. But I don't know how they are working with the actual data and displaying it. I am starting to regret posting an answer to his question. :sigh:

      realJSOPR 1 Reply Last reply
      0
      • S Slacker007

        c# - How to set DateTime to null - Stack Overflow[^]

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #11

        That's not what I would call a reasonable practice. I prefer my DateTimes to be valid in some way (and use new DateTime(0) to accomplish that).

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

        S 1 Reply Last reply
        0
        • S Slacker007

          Of course you can't. But I don't know how they are working with the actual data and displaying it. I am starting to regret posting an answer to his question. :sigh:

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #12

          Slacker007 wrote:

          I am starting to regret posting an answer to his question. :sigh:

          Waaa-waaaa-waaaaaaaaaaa. :)

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

          S 1 Reply Last reply
          0
          • realJSOPR realJSOP

            That's not what I would call a reasonable practice. I prefer my DateTimes to be valid in some way (and use new DateTime(0) to accomplish that).

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

            S Offline
            S Offline
            Slacker007
            wrote on last edited by
            #13

            John Simmons / outlaw programmer wrote:

            That's not what I would call a reasonable practice.

            It is a possible and valid scenario, whether you John, agree with it or not. Just saying... For instance, shipping dates - they are usually null until something actually ships.

            realJSOPR L 2 Replies Last reply
            0
            • realJSOPR realJSOP

              Slacker007 wrote:

              I am starting to regret posting an answer to his question. :sigh:

              Waaa-waaaa-waaaaaaaaaaa. :)

              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
              -----
              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
              -----
              When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

              S Offline
              S Offline
              Slacker007
              wrote on last edited by
              #14

              You know John, you don't "always" have to be an asshole.

              realJSOPR 1 Reply Last reply
              0
              • S Slacker007

                You know John, you don't "always" have to be an asshole.

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #15

                Yes. Yes, I do. If I wasn't always an assh*le, I would disappoint my legions of fans. Besides, me being an assh*le is really the only constant in life any more that absolutely EVERYBODY can count on. Beyond that, I was just poking you in the ribs. If you're honestly butt-hurt, I can call a waaa-mbulance for you. :) BTW, I'm the one that voted your original answer a 5.

                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                -----
                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                -----
                When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                1 Reply Last reply
                0
                • S Slacker007

                  John Simmons / outlaw programmer wrote:

                  That's not what I would call a reasonable practice.

                  It is a possible and valid scenario, whether you John, agree with it or not. Just saying... For instance, shipping dates - they are usually null until something actually ships.

                  realJSOPR Offline
                  realJSOPR Offline
                  realJSOP
                  wrote on last edited by
                  #16

                  We can argue the validity of nulls all day. I don't like 'em, and I strive to resolve them in some way.

                  ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                  -----
                  You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                  -----
                  When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                  1 Reply Last reply
                  0
                  • S Slacker007

                    John Simmons / outlaw programmer wrote:

                    That's not what I would call a reasonable practice.

                    It is a possible and valid scenario, whether you John, agree with it or not. Just saying... For instance, shipping dates - they are usually null until something actually ships.

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #17

                    One would use a "shipped event", in that case. One could drop and smash the shipment .... One does not carry a null "damaged date" in anticipation.

                    1 Reply Last reply
                    0
                    • A abdul subhan mohammed

                      sorry for that, plz help me.

                      D Offline
                      D Offline
                      deepankarbhatnagar
                      wrote on last edited by
                      #18

                      This is not the correct place to write this content.

                      hi

                      1 Reply Last reply
                      0
                      • S Slacker007

                        I would not use Convert.ToDateTime with a text/string input. Instead try using TryParse with datetime. DateTime.TryParse Method (String, DateTime) (System)[^]

                        C Offline
                        C Offline
                        ch nagaraju
                        wrote on last edited by
                        #19

                        HOW TO RECTIFY ERROR

                        S realJSOPR 2 Replies Last reply
                        0
                        • C ch nagaraju

                          HOW TO RECTIFY ERROR

                          S Offline
                          S Offline
                          Slacker007
                          wrote on last edited by
                          #20

                          Why are you yelling at me?

                          1 Reply Last reply
                          0
                          • C ch nagaraju

                            HOW TO RECTIFY ERROR

                            realJSOPR Offline
                            realJSOPR Offline
                            realJSOP
                            wrote on last edited by
                            #21

                            Read the whole thread - the answer is there.

                            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                            -----
                            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                            -----
                            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                            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