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. The Lounge
  3. Bug of the Day

Bug of the Day

Scheduled Pinned Locked Moved The Lounge
databasedebuggingjsonhelp
39 Posts 19 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.
  • C Chris Maunder

    I'm trying to set a value to the maximum smalldatetime allowed in SQL, yet what's appearing is "6 June 1979". Nothing I do seems to work: ensuring Culture is OK, ensuring I'm passing dates around in a sensible format, ensuring the data I'm setting is the actual date I'm setting. In the debugger I see _date with a value of "6/06/2079 12:00:00 AM" (see rant below). The date is fine. I pass this into a formatter to turn it into "dd-MMM-yy" format. That works perfectly and the output is correct. This string goes to the user, they hit submit, it comes back and is parsed fine. Everything works perfectly. Except the date always comes back as 1979. ARGH. And then I spot it. 15 years too late I've been hit by the Y2K bug. 6/06/2079 12:00:00 AM is 6 Jun 2079 -> "6-Jun-79" which is parsed as 6-Jun-1979. /more coffee, then better formatting. As a side note: The American date format (mm/dd/yyyy) is painfully and dangerously ambiguous so given that OS installs are often set with US as the region, surely debuggers should display dates and times as dd-MMM-yyyy or even better, yyyy-mm-dd to account for the Rest Of The World who wants to scream everytime they get an email saying "the date is 4/7/2015".

    cheers Chris Maunder

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

    Sure, blame it on the Americans. ;)

    1 Reply Last reply
    0
    • L Lost User

      The American date format of MM/DD/YYYY is simply idiotic, as is our ridiculous clinging to Imperial measurements, when the metric system makes so much more sense. Why? I believe we Americans are just too lazy to adapt to a new system, despite the fact that it just makes sense to do so! OK, I have my coat and am long gone! ;P

      How do we preserve the wisdom men will need, when their violent passions are spent? - The Lost Horizon

      W Offline
      W Offline
      W Balboos GHB
      wrote on last edited by
      #22

      Now I prefer YYYYMMDD because it's great for easy sorting of things, even as text. But as for the metric system being better? Nonsense. The US system is far more savvy with the modern way of doing things. Start with an OUNCE. 2^2 Ounces is a Gil 2^3 Ounces is a Cup 2^4 Ounces is a Pint 2^5 Ounces is a Quart 2^7 Ounces is a Gallon. Quarts can also, by powers of 2, be expanded to bushels and pecks. So - obviously - the US system of measurements is perfect for the computer age. Clean, efficient, and fast (one can even use shift operators - try that with metric). No roundoff errors. No approximations.

      PERFECTION

      "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

      "As far as we know, our computer has never had an undetected error." - Weisert

      "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

      1 Reply Last reply
      0
      • C Colin Mullikin

        As far as date is concerned, I prefer the "July 22, 2015" format. There is no room for ambiguity. However, when it comes to Imperial v. Metric. I am strictly in the Metric for science, Imperial for every day use camp. For instance, I have an intuition for how far a mile is, or how much a 50lb bag of sand weighs, but I have no clue how far a kilometer is or how much a 50kg bag of sand might weigh. Yes, I know what the conversion factors are, but I have to think about it, then convert to Imperial, just so I can be in the right ballpark. You could say, "Oh, well to Hell with current adults, we should do it for the children." But that creates a problem, because then you have two generations, who are in close proximity (parent/child relationships), using two different systems, and if the Common Core Math standards have taught us anything, it's that parents get really pissed when they're too stubborn and/or stupid to learn how to do their children's math homework.

        The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

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

        Colin Mullikin wrote:

        For instance, I have an intuition for how far a mile is, or how much a 50lb bag of sand weighs, but I have no clue how far a kilometer is or how much a 50kg bag of sand might weigh.

        Only because you've been brought up using the Imperial scale. I was born decades after India went metric and I have no idea how "long" a mile is or how much 5 lb "weighs".

        Cheers, विक्रम "We have already been through this, I am not going to repeat myself." - fat_boy, in a global warming thread :doh:

        1 Reply Last reply
        0
        • L Lost User

          I lived through the transition from the imperial system to the metric system in South Africa so I do have some experience in both systems. As far as I am concerned there is no choice: Metric is head and shoulders better than imperial! I also experienced the transition of the monetary system from pounds/shillings/pence to the current metric equivalent in SA and the UK. In SA the transition was overnight. Pounds were withdrawn from circulation in a matter of days. In the UK it took months as they chose to run a dual system for months. Very painful! Nobody will ever convince me that imperial is better!

          How do we preserve the wisdom men will need, when their violent passions are spent? - The Lost Horizon

          J Offline
          J Offline
          jsc42
          wrote on last edited by
          #24

          In the UK, pounds were not withdrawn. A pre-decimal pound and a post-decimal pound were the same. Only the sub units were changed from good mini radix numbers or 20 and 12 to very poor calculation number 100. Even now, the UK is consistent - a pound is a measure of money and a measure of weight. What could be simpler than using the same unit name for multiple types of unit? But, you could buy a lot more with a pre-decimal £1 than you can buy now.

          1 Reply Last reply
          0
          • C Chris Maunder

            I'm trying to set a value to the maximum smalldatetime allowed in SQL, yet what's appearing is "6 June 1979". Nothing I do seems to work: ensuring Culture is OK, ensuring I'm passing dates around in a sensible format, ensuring the data I'm setting is the actual date I'm setting. In the debugger I see _date with a value of "6/06/2079 12:00:00 AM" (see rant below). The date is fine. I pass this into a formatter to turn it into "dd-MMM-yy" format. That works perfectly and the output is correct. This string goes to the user, they hit submit, it comes back and is parsed fine. Everything works perfectly. Except the date always comes back as 1979. ARGH. And then I spot it. 15 years too late I've been hit by the Y2K bug. 6/06/2079 12:00:00 AM is 6 Jun 2079 -> "6-Jun-79" which is parsed as 6-Jun-1979. /more coffee, then better formatting. As a side note: The American date format (mm/dd/yyyy) is painfully and dangerously ambiguous so given that OS installs are often set with US as the region, surely debuggers should display dates and times as dd-MMM-yyyy or even better, yyyy-mm-dd to account for the Rest Of The World who wants to scream everytime they get an email saying "the date is 4/7/2015".

            cheers Chris Maunder

            M Offline
            M Offline
            Mark Starr
            wrote on last edited by
            #25

            Depending on your SQL version - check your 2 digit year cutoff option: https://technet.microsoft.com/en-us/library/ms189577(v=sql.105).aspx[^] As for internationalization of date formats - we've been using dd-Mmm-yyyy for years, but much of our industry is going to the ISO-8601 standard yyyy-mm-yy. (even our sales/support people use "ISO-8601" in conversation now.) I know this was supposed to be a rant thread, but I get worked up about date formats.

            1 Reply Last reply
            0
            • L Lost User

              I think the reason it was done is plain - Americans (and some others) tend to say When speaking it is rare to include the Year It is sensible to speak the largest part first So - June 5th narrows down the target as it is spoken - ideal! So Yanks take that as 6/5 Then slam the date on the wrong end because it seems less important to them. Idiotic - but then so is belief that the constitution means you can own an arsenal many a small country would be proud to own...

              PooperPig - Coming Soon

              9 Offline
              9 Offline
              9082365
              wrote on last edited by
              #26

              But .. but ... when you ask someone the date they usually just give you the day, assuming that you're not so divorced from temporal reality that you can't pinpoint the month for yourself. And in formal situations such as a legal document you'd have to say 'this third day of September in the year of our Lord 1784' because 'September, this third day of' etc. just doesn't make sense. And surely it's legal usage that sets the template for such things not the informal?

              M L 2 Replies Last reply
              0
              • 9 9082365

                But .. but ... when you ask someone the date they usually just give you the day, assuming that you're not so divorced from temporal reality that you can't pinpoint the month for yourself. And in formal situations such as a legal document you'd have to say 'this third day of September in the year of our Lord 1784' because 'September, this third day of' etc. just doesn't make sense. And surely it's legal usage that sets the template for such things not the informal?

                M Offline
                M Offline
                mBuchwald
                wrote on last edited by
                #27

                "When is you birthday?" : "July 4th." "When Mark's party? "November 12th" Month-Day answers to questions in everyday conversation.

                1 Reply Last reply
                0
                • 9 9082365

                  How does the metric system make more sense? It's no less arbitrary and the assumption that people will find the arithmetic less difficult is highly doubtful (shortly after we decimalised currency in the UK I was delayed by several minutes in a shop because the assistant needed to fetch a calculator to work out a 10% discount!) The imperial weights fit particularly well with the quantities of things that people might want to buy - I know exactly what I'm getting in a quarter of mushrooms, an ounce of yeast or a pound of mince and so that's what I continue to ask for despite the EU's attempts to homogenise us all with baffling amounts. Long live the pound, the pint and the mile, I say. And to return the date. It is of course the departure from the Imperial norm made by Americans (when and why I have yet to discover) that causes all the problems. Who else could come up with a system that takes a unit from its rightful place in between the lower and the higher and sticks it at the front? You don't do mm:hh:ss so why MM:dd:yy Bewildering!

                  M Offline
                  M Offline
                  Member_5893260
                  wrote on last edited by
                  #28

                  Look at SI Units: the metric system makes more sense simply because things equate to one another properly, and everything matches up. Imperial units just don't work that way: when you're trying to do anything with mechanical engineering involving equations, the calculations fail because the results are numbers which don't match the measurements they're supposed to be expressed in. When American engineers want to build complex systems, they have to measure everything in imperial units, convert to SI units, do the work, then convert everything back to imperial units again in order to build whatever it is they're going to build. I choose to believe that this is why American car engines need four litres of displacement to produce less power than European or Japanese engines half the size can generate.

                  9 1 Reply Last reply
                  0
                  • M Member_5893260

                    Look at SI Units: the metric system makes more sense simply because things equate to one another properly, and everything matches up. Imperial units just don't work that way: when you're trying to do anything with mechanical engineering involving equations, the calculations fail because the results are numbers which don't match the measurements they're supposed to be expressed in. When American engineers want to build complex systems, they have to measure everything in imperial units, convert to SI units, do the work, then convert everything back to imperial units again in order to build whatever it is they're going to build. I choose to believe that this is why American car engines need four litres of displacement to produce less power than European or Japanese engines half the size can generate.

                    9 Offline
                    9 Offline
                    9082365
                    wrote on last edited by
                    #29

                    I find it very difficult to believe that that's what any engineer does in reality but then this is the weirdest pro point I've ever come across. The equations that were created using SI units don't work with Imperial measurements? Gee, how did they ever do science before SI units then. Oh ... right ... they used equations that were created using Imperial units. The fundamental physical relationships don't change because you change the units that you measure values in, and in most cases there isn't even any need to modify the equation; s = d/t and F = ma whether you measure in metres, feet or cubits, kilograms, pounds or (idealised) chihuahuas!

                    M 1 Reply Last reply
                    0
                    • 9 9082365

                      How does the metric system make more sense? It's no less arbitrary and the assumption that people will find the arithmetic less difficult is highly doubtful (shortly after we decimalised currency in the UK I was delayed by several minutes in a shop because the assistant needed to fetch a calculator to work out a 10% discount!) The imperial weights fit particularly well with the quantities of things that people might want to buy - I know exactly what I'm getting in a quarter of mushrooms, an ounce of yeast or a pound of mince and so that's what I continue to ask for despite the EU's attempts to homogenise us all with baffling amounts. Long live the pound, the pint and the mile, I say. And to return the date. It is of course the departure from the Imperial norm made by Americans (when and why I have yet to discover) that causes all the problems. Who else could come up with a system that takes a unit from its rightful place in between the lower and the higher and sticks it at the front? You don't do mm:hh:ss so why MM:dd:yy Bewildering!

                      R Offline
                      R Offline
                      RandyWester
                      wrote on last edited by
                      #30

                      Why do Americans call it the 'Fourth of July' and write 07/04/2015? So much simpler if we all used the ISO 2015-07-04. I work with financial data that often can't be directly copied and pasted from web sites and PDF documents into other programs. I thought that was going to be fixed in the Windows 3.1 upgrade.

                      1 Reply Last reply
                      0
                      • 9 9082365

                        I find it very difficult to believe that that's what any engineer does in reality but then this is the weirdest pro point I've ever come across. The equations that were created using SI units don't work with Imperial measurements? Gee, how did they ever do science before SI units then. Oh ... right ... they used equations that were created using Imperial units. The fundamental physical relationships don't change because you change the units that you measure values in, and in most cases there isn't even any need to modify the equation; s = d/t and F = ma whether you measure in metres, feet or cubits, kilograms, pounds or (idealised) chihuahuas!

                        M Offline
                        M Offline
                        Member_5893260
                        wrote on last edited by
                        #31

                        Wrong. There's a concept of coherence in systems of measurement: as described here[^]. Before this, doing science was significantly harder. The imperial system is NOT a coherent system of measurement, and thus calculations don't work. So, as I said before, you have to convert everything into SI units, do the calculation and then convert it all back again afterwards, otherwise you're forever trying to figure out how many of each unit of whatever measurement you started with end up figuring into whatever units you want to end up with.

                        9 U 2 Replies Last reply
                        0
                        • M Member_5893260

                          Wrong. There's a concept of coherence in systems of measurement: as described here[^]. Before this, doing science was significantly harder. The imperial system is NOT a coherent system of measurement, and thus calculations don't work. So, as I said before, you have to convert everything into SI units, do the calculation and then convert it all back again afterwards, otherwise you're forever trying to figure out how many of each unit of whatever measurement you started with end up figuring into whatever units you want to end up with.

                          9 Offline
                          9 Offline
                          9082365
                          wrote on last edited by
                          #32

                          No. The arithmetic was more difficult. The science was completely unaffected. Almost all the significant engineering formulae were discovered before the metric system was even a glint in someone's eye and more than a few even predate the Imperial system. Ultimately the mathematics of science is always shoehorned into the measurement system of the day which is always arbitrary. There is no such thing as a coherent measurement system whatever way you cut it. There is no more logic to making your measuring stick the length of a fraction of the Earth's circumference (which in itself is an idealised length) than the average length of a male adult's foot. Simply because you have a name for a derived unit such as the newton doesn't change the fact that it is a derived (and arbitrary!) unit. There is no more coherence to the concept it disguises, it is a measure of mass multiplied by acceleration. 1N = 1m/s^2 is no more nor less consistent and coherent than 1 Tortoise Pull = 0.0013 dog tails per eyeblink ^2. The only difference is the speed of calculation (measured in camel heartbeats, obviously)! Anyone who thinks that SI units are any less arbitrary than any other measuring sytem or fit more closely the natural spans of the Universe and the laws of physics they clearly haven't taken a look at the definition of those units recently (the second is a doozie!). The SI system is a convenience for scientists. It no more reflects the real world and how it's put together than the scribblings of a madman!

                          M 1 Reply Last reply
                          0
                          • 9 9082365

                            No. The arithmetic was more difficult. The science was completely unaffected. Almost all the significant engineering formulae were discovered before the metric system was even a glint in someone's eye and more than a few even predate the Imperial system. Ultimately the mathematics of science is always shoehorned into the measurement system of the day which is always arbitrary. There is no such thing as a coherent measurement system whatever way you cut it. There is no more logic to making your measuring stick the length of a fraction of the Earth's circumference (which in itself is an idealised length) than the average length of a male adult's foot. Simply because you have a name for a derived unit such as the newton doesn't change the fact that it is a derived (and arbitrary!) unit. There is no more coherence to the concept it disguises, it is a measure of mass multiplied by acceleration. 1N = 1m/s^2 is no more nor less consistent and coherent than 1 Tortoise Pull = 0.0013 dog tails per eyeblink ^2. The only difference is the speed of calculation (measured in camel heartbeats, obviously)! Anyone who thinks that SI units are any less arbitrary than any other measuring sytem or fit more closely the natural spans of the Universe and the laws of physics they clearly haven't taken a look at the definition of those units recently (the second is a doozie!). The SI system is a convenience for scientists. It no more reflects the real world and how it's put together than the scribblings of a madman!

                            M Offline
                            M Offline
                            Member_5893260
                            wrote on last edited by
                            #33

                            I think you've just made my point for me with the phrases "the arithmetic was more difficult" and "The SI system is a convenience for scientists." Look at how SI units interlock, and how you can perform one calculation after another, from unit to unit, and it all maintains coherence. The Imperial system can't do that.

                            9 1 Reply Last reply
                            0
                            • 9 9082365

                              But .. but ... when you ask someone the date they usually just give you the day, assuming that you're not so divorced from temporal reality that you can't pinpoint the month for yourself. And in formal situations such as a legal document you'd have to say 'this third day of September in the year of our Lord 1784' because 'September, this third day of' etc. just doesn't make sense. And surely it's legal usage that sets the template for such things not the informal?

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

                              Member 9082365 wrote:

                              And surely it's legal usage that sets the template for such things not the informal?

                              I don't think so! I think this is an example of evolution in the same way that changing spellings and pronunciations are. Nobody sat down and thought "Hmm -= what format should we use for dates?" If they had we'd have been using a decimal calendar !

                              PooperPig - Coming Soon

                              9 1 Reply Last reply
                              0
                              • M Member_5893260

                                Wrong. There's a concept of coherence in systems of measurement: as described here[^]. Before this, doing science was significantly harder. The imperial system is NOT a coherent system of measurement, and thus calculations don't work. So, as I said before, you have to convert everything into SI units, do the calculation and then convert it all back again afterwards, otherwise you're forever trying to figure out how many of each unit of whatever measurement you started with end up figuring into whatever units you want to end up with.

                                U Offline
                                U Offline
                                User 11704479
                                wrote on last edited by
                                #35

                                Don't know what type of engineering you are referring to but I work in Structural Engineering in the US and nothing gets converted to SI and back. That said, I would much prefer using the metric system.

                                M 1 Reply Last reply
                                0
                                • M Member_5893260

                                  I think you've just made my point for me with the phrases "the arithmetic was more difficult" and "The SI system is a convenience for scientists." Look at how SI units interlock, and how you can perform one calculation after another, from unit to unit, and it all maintains coherence. The Imperial system can't do that.

                                  9 Offline
                                  9 Offline
                                  9082365
                                  wrote on last edited by
                                  #36

                                  Yes, it can, and did so very successfully for centuries. It would simply need updating with a few additional units to cope perfectly adequately with modern scientific calculations. There are, indeed, many international conventions which still use Imperial such as feet for aircraft heights, knots for boat speeds, and fathoms for water depth. I certainly don't expect the death of horsepower any time soon. And as someone else pointed out backing the metric system has proved to be a complete misstep with the arrival of computers as base 10 is the absolute worst for computer calculations with just two factors (2 and 5) making it all but impossible to express part units accurately in binary code. In the digital age decimal units are the dinosaurs.

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    Member 9082365 wrote:

                                    And surely it's legal usage that sets the template for such things not the informal?

                                    I don't think so! I think this is an example of evolution in the same way that changing spellings and pronunciations are. Nobody sat down and thought "Hmm -= what format should we use for dates?" If they had we'd have been using a decimal calendar !

                                    PooperPig - Coming Soon

                                    9 Offline
                                    9 Offline
                                    9082365
                                    wrote on last edited by
                                    #37

                                    Well obviously somebody did sit down and think what format should the USA use for dates at some point or there wouldn't be agreement on the standard form used in business etc. (especially so as the format is different to the one that European settlers would have brought with them). It may be lost to us now but somewhere at some time there was a declaration made enshrining the 'new' format.

                                    L 1 Reply Last reply
                                    0
                                    • 9 9082365

                                      Well obviously somebody did sit down and think what format should the USA use for dates at some point or there wouldn't be agreement on the standard form used in business etc. (especially so as the format is different to the one that European settlers would have brought with them). It may be lost to us now but somewhere at some time there was a declaration made enshrining the 'new' format.

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

                                      I don't think so I think it's a 'defacto' standard.

                                      PooperPig - Coming Soon

                                      1 Reply Last reply
                                      0
                                      • U User 11704479

                                        Don't know what type of engineering you are referring to but I work in Structural Engineering in the US and nothing gets converted to SI and back. That said, I would much prefer using the metric system.

                                        M Offline
                                        M Offline
                                        Member_5893260
                                        wrote on last edited by
                                        #39

                                        This would be mechanical engineering for things like cars, planes, etc. If you start doing fuel/mass/acceleration/... calculations, you'll be wanting SI units for sure.

                                        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