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. Other Discussions
  3. Clever Code
  4. Spring is here!

Spring is here!

Scheduled Pinned Locked Moved Clever Code
databasehelpjavasysadminalgorithms
12 Posts 9 Posters 2 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.
  • G Offline
    G Offline
    GDavy
    wrote on last edited by
    #1

    Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)

    C P R 3 Replies Last reply
    0
    • G GDavy

      Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      Interesting developer experience, but definitely: W R O N G F O R U M! Sorry. :) Nevermind. Maybe I was a bit drastic.

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

      modified on Friday, March 28, 2008 9:16 AM

      D Q 2 Replies Last reply
      0
      • C CPallini

        Interesting developer experience, but definitely: W R O N G F O R U M! Sorry. :) Nevermind. Maybe I was a bit drastic.

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        modified on Friday, March 28, 2008 9:16 AM

        D Offline
        D Offline
        Dan Neely
        wrote on last edited by
        #3

        ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.

        Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull

        C R P 3 Replies Last reply
        0
        • D Dan Neely

          ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.

          Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          Uhm, maybe. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          1 Reply Last reply
          0
          • C CPallini

            Interesting developer experience, but definitely: W R O N G F O R U M! Sorry. :) Nevermind. Maybe I was a bit drastic.

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

            modified on Friday, March 28, 2008 9:16 AM

            Q Offline
            Q Offline
            QuiJohn
            wrote on last edited by
            #5

            I think you posted your wrong forum message to the wrong forum.


            Faith is a fine invention For gentlemen who see; But microscopes are prudent In an emergency!            -Emily Dickinson

            C C 2 Replies Last reply
            0
            • Q QuiJohn

              I think you posted your wrong forum message to the wrong forum.


              Faith is a fine invention For gentlemen who see; But microscopes are prudent In an emergency!            -Emily Dickinson

              C Offline
              C Offline
              CPallini
              wrote on last edited by
              #6

              OK, I've already modified my original reply. :)

              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

              1 Reply Last reply
              0
              • G GDavy

                Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)

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

                Which is why we (enlightented developers) use DateTime rather than integer seconds. It's also why we (enlightented developers) use UTC rather than local time. Problems like you described should not have escaped the twentieth century. Learn from history.

                GDavy wrote:

                31/03/2008 00:00:00 (12pm).

                That's 12AM isn't it? Which brings to mind a third-party product we (my current employer) used which stored time as integer seconds since 1970-01-01 (in UTC), but when only the date was important they stored 12:00 (rather than 00:00) in the time.

                1 Reply Last reply
                0
                • Q QuiJohn

                  I think you posted your wrong forum message to the wrong forum.


                  Faith is a fine invention For gentlemen who see; But microscopes are prudent In an emergency!            -Emily Dickinson

                  C Offline
                  C Offline
                  Chris Maunder
                  wrote on last edited by
                  #8

                  I think I just had a stack overflow.

                  cheers, Chris Maunder

                  CodeProject.com : C++ MVP

                  1 Reply Last reply
                  0
                  • G GDavy

                    Yep, indeed spring has come, and my application knew it. What happened: I build a WinCe application used in stores for making orders, inventories, etc... Note that the devices used have very strict memory limitations so no SQL DB server fits on them, the whole DB system is written in-house. One of the functionalities it has, is when you make an order for a specific day, you see how much was ordered the previous days for each item you order. 4 months passed with only positive feedback, and yesterday I got a call. Super urgent, major bug, the ordered amounts of previous days are all lost. :~ I swollowed, cold sweat started flowing down my back, with fake optimism I tell that stuff probably isn't as bad as the customer lets shine through (hoping that it is just another case of user-mistake. It's really amazing what 'bugs' users can come up with that aren't bugs). Anyway they send me a dump of the problematic DB. Scanning it quickly with my DB-viewer I notice that the data is all there (pfew, already a big relief, no data was lost/corrupted due to a bug). Running the actual application using that DB I indeed see that there doesn't seem to be any data available for previous days (the date for which the order is being made is 31/03/2008). I step through the code and can't see any mistake, it worked for 4+ months and now suddenly it doesn't :confused:. And then it hit me! In the DB we save the dates as the numbers of seconds since 1/1/1970. So, for dates where time doesn't matter, they are saved as e.g. 31/03/2008 00:00:00 (12pm). To find how much was ordered x days before the specific day, we substract x days from that date and look for the ordered amount on that date (if there is any). What was the problem now: This sunday: 30/03/2008 the time is being set 1 hour forward, so it has only 23 hours, this means that using my original code, when I want to see what was ordered 2 days before I calculated: 31/03/2008 00:00:00 - 2days (read 48hours).This however is not the expected 29/03/2008 00:00:00 but due to the hour change: 28/03/2008 23:00:00. So searching ordered amounts for that date resulted in nothing :doh:. Well I must say it was an interesting bug, that had me scratching my head for a little while :)

                    R Offline
                    R Offline
                    ravtos
                    wrote on last edited by
                    #9

                    I think it's definitely a bug, but not a subtle one.

                    GDavy wrote:

                    the whole DB system is written in-house.

                    So it's you or your co-workers who forgot about time changes, did your forgot about leap years too? Did you managed to repair this, or you gonna have similar problem in about half a year? Another thing is why your are inventing wheel again, when you have ready functions to operate on date/time.. I would call it a WTF[^] I rest my case.. ;)

                    Communism doesn't work because people like to own stuff. Frank Zappa

                    G 1 Reply Last reply
                    0
                    • R ravtos

                      I think it's definitely a bug, but not a subtle one.

                      GDavy wrote:

                      the whole DB system is written in-house.

                      So it's you or your co-workers who forgot about time changes, did your forgot about leap years too? Did you managed to repair this, or you gonna have similar problem in about half a year? Another thing is why your are inventing wheel again, when you have ready functions to operate on date/time.. I would call it a WTF[^] I rest my case.. ;)

                      Communism doesn't work because people like to own stuff. Frank Zappa

                      G Offline
                      G Offline
                      GDavy
                      wrote on last edited by
                      #10

                      s.t.a.v.o wrote:

                      your are inventing wheel again, when you have ready functions to operate on date/time.

                      I do not see where the wheel is re-invented here. The application is written in embedded Visual C++ 4.0. Simple example: I'll use:

                      s.t.a.v.o wrote:

                      ready functions to operate on date/time

                      Imagine you have a function that gets a CTime input and outputs as a string the day before the input date: void PreviousDayAsString(CTime aDay, CString& dayBefore) { aDay -= CTimeSpan(1,0,0,0); //substract 1day dayBefore.Format(_T("%02d-%02d-%d"), aDay.GetDay(), aDay.GetMonth(), aDay.GetYear()); } if the input date is 31/03/2008 00:00:00 (12am) then output string is 29-03-2008. Tell me where the wheel is reinvented and what is WTF about this seemingly simple, logic piece of code. I rest my case. ;P

                      1 Reply Last reply
                      0
                      • D Dan Neely

                        ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.

                        Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull

                        R Offline
                        R Offline
                        Rahul Deo Bharadwaj
                        wrote on last edited by
                        #11

                        Hi We are looking for webmethods professionals for south africa . experience in BAM is absolutely necessary. please call on 04040150478 or 9849128646. regards Rahul www.binaryberries.com

                        1 Reply Last reply
                        0
                        • D Dan Neely

                          ummm getting burned by daylight savings shifts certainly seems like s subtle bug to me.

                          Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop. -- Matthew Faithfull

                          P Offline
                          P Offline
                          Paul Conrad
                          wrote on last edited by
                          #12

                          dan neely wrote:

                          getting burned by daylight savings shifts certainly seems like s subtle bug to me.

                          I agree. This is July and I am finally getting used to it :-\

                          "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon

                          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