Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 8, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 8, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 8, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 8, 2025

      Xbox handheld leaks in new “Project Kennan” photos from the FCC — plus an ASUS ROG Ally 2 prototype with early specs

      May 8, 2025

      OpenAI plays into Elon Musk’s hands, ditching for-profit plan — but Sam Altman doesn’t have Microsoft’s blessing yet

      May 8, 2025

      “Are we all doomed?” — Fiverr CEO Micha Kaufman warns that AI is coming for all of our jobs, just as Bill Gates predicted

      May 8, 2025

      I went hands-on with dozens of indie games at Gamescom Latam last week — You need to wishlist these 7 titles right now

      May 8, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      NativePHP Hit $100K — And We’re Just Getting Started 🚀

      May 8, 2025
      Recent

      NativePHP Hit $100K — And We’re Just Getting Started 🚀

      May 8, 2025

      Mastering Node.js Streams: The Ultimate Guide to Memory-Efficient File Processing

      May 8, 2025

      Sitecore PowerShell commands – XM Cloud Content Migration

      May 8, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      8 Excellent Free Books to Learn Julia

      May 8, 2025
      Recent

      8 Excellent Free Books to Learn Julia

      May 8, 2025

      Janus is a general purpose WebRTC server

      May 8, 2025

      12 Best Free and Open Source Food and Drink Software

      May 8, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: Leap to the Past

    CodeSOD: Leap to the Past

    May 8, 2025

    Early in my career, I had the misfortune of doing a lot of Crystal Reports work. Crystal Reports is another one of those tools that lets non-developer, non-database savvy folks craft reports. Which, like so often happens, means that the users dig themselves incredible holes and need professional help to get back out, because at the end of the day, when the root problem is actually complicated, all the helpful GUI tools in the world can’t solve it for you.

    Michael was in a similar position as I was, but for Michael, there was a five alarm fire. It was the end of the month, and a bunch of monthly sales reports needed to be calculated. One of the big things management expected to see was a year-over-year delta on sales, and they got real cranky if the line didn’t go up. If they couldn’t even see the line, they went into a full on panic and assumed the sales team was floundering and the company was on the verge of collapse.

    Unfortunately, the report was spitting out an error: “A day number must be between 1 and the number of days in the month.”

    Michael dug in, and found this “delight” inside of a function called one_year_ago:

    
    Local StringVar yearStr  := Left({?ReportToDate}, 4);
    Local StringVar monthStr := Mid({?ReportToDate}, 5, 2); 
    Local StringVar dayStr   := Mid({?ReportToDate}, 7, 2);
    Local StringVar hourStr  := Mid({?ReportToDate}, 9, 2);
    Local StringVar minStr   := Mid({?ReportToDate}, 11, 2);
    Local StringVar secStr   := Mid({?ReportToDate}, 13, 2);
    Local NumberVar LastYear;
    
    LastYear := ToNumber(YearStr) - 1;
    YearStr := Replace (toText(LastYear),'.00' , '' );
    YearStr := Replace (YearStr,',' , '' );
    
    //DateTime(year, month, day, hour, min, sec);
    //Year + Month + Day + Hour + min + sec;  // string value
    DateTime(ToNumber(YearStr), ToNumber(MonthStr), ToNumber(dayStr), ToNumber(HourStr), ToNumber(MinStr),ToNumber(SecStr) );
    

    We’ve all seen string munging in date handling before. That’s not surprising. But what’s notable about this one is the day on which it started failing. As stated, it was at the end of the month. But which month? February. Specifically, February 2024, a leap year. Since they do nothing to adjust the dayStr when constructing the date, they were attempting to construct a date for 29-FEB-2023, which is not a valid date.

    Michael writes:

    Yes, it’s Crystal Reports, but surprisingly not having date manipulation functions isn’t amongst it’s many, many flaws. It’s something I did in a past life isn’t it??

    The fix was easy enough- rewrite the function to actually use date handling. This made a simpler, basically one-line function, using Crystal’s built in functions. That fixed this particular date handling bug, but there were plenty more places where this kind of hand-grown string munging happened, and plenty more opportunities for the report to fail.

    [Advertisement]
    ProGet’s got you covered with security and access controls on your NuGet feeds. Learn more.

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleXigmaNAS – storage NAS distribution
    Next Article openSUSE rimuove l’ambiente desktop Deepin dai suoi repository software

    Related Posts

    News & Updates

    Xbox handheld leaks in new “Project Kennan” photos from the FCC — plus an ASUS ROG Ally 2 prototype with early specs

    May 8, 2025
    News & Updates

    OpenAI plays into Elon Musk’s hands, ditching for-profit plan — but Sam Altman doesn’t have Microsoft’s blessing yet

    May 8, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    Community News: Latest PECL Releases (07.16.2024)

    Development

    Framework Laptop 13 will be enhanced with RISC-V architecture, a viable ARM alternative

    Development

    CVE-2024-8100 – Arista CloudVision Portal – Token Privilege Escalation

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-3986 – Apache Apereo CAS Regular Expression Inefficient Complexity Remote Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    WordPress-sites aangevallen via kritiek lek in OttoKit-plug-in

    May 7, 2025

    WordPress-sites aangevallen via kritiek lek in OttoKit-plug-in

    WordPress-sites worden aangevallen via een kritieke kwetsbaarheid in de plug-in OttoKit, die eerder nog bekend stond als SureTriggers. Via het beveiligingslek kan een ongeauthenticeerde aanvaller admi …
    Read more

    Published Date:
    May 07, 2025 (3 hours, 31 minutes ago)

    Vulnerabilities has been mentioned in this article.

    CVE-2025-27007

    CVE-2025-3102

    Your Meta Ray-Bans just got a big update for free – and it feels like science fiction

    April 23, 2025

    Latest and Oldest Relationship Methods in Laravel

    February 25, 2025

    Samsung Health is adding these personalized wellness features – and they’re much needed

    January 22, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.