Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-2714

LP:603750 - Problems with curdate()-1 function when is first day of the month

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Not a Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      Description

      curdate() function is for get current date value, acording documentation when you use: curdate()-1 you will obtain yesterday date value, but when is the first day of the month (for example: July 1, 2010) you got a wrong value!, you will get July 0, 2010 in our example (20100700).

      To avoid this I use: from_unixtime(unix_timestamp(curdate()) - 86400)

      but I think that curdate()-1 function have to work fine every day and not only when curent day of the month is greater than 1

      I am using: 5.1.42-MariaDB-mariadb73 version
      and my operating system is: GNU/Linux Debian Lenny Kernel 2.6.26-2-686
      platform: i686

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            philipstoev Philip Stoev added a comment -

            Re: Problems with curdate()-1 function when is first day of the month
            Hello, the minus operator in your case operates on integers and is not aware of dates, so it returns an integer even though the integer is not a valid date. The correct syntax is :

            SELECT CURDATE() - INTERVAL 1 DAY ;

            or

            SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) ;

            Can you please point out the location in the documentation where you took your query from?

            Show
            philipstoev Philip Stoev added a comment - Re: Problems with curdate()-1 function when is first day of the month Hello, the minus operator in your case operates on integers and is not aware of dates, so it returns an integer even though the integer is not a valid date. The correct syntax is : SELECT CURDATE() - INTERVAL 1 DAY ; or SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY) ; Can you please point out the location in the documentation where you took your query from?
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 603750

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 603750

              People

              • Assignee:
                Unassigned
                Reporter:
                pabloalejandromanyomavallejos Pablo Alejandro Manyoma Vallejos
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: