[MDEV-2714] LP:603750 - Problems with curdate()-1 function when is first day of the month Created: 2010-07-09  Updated: 2012-10-04  Resolved: 2012-10-04

Status: Closed
Project: MariaDB Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Pablo Alejandro Manyoma Vallejos (Inactive) Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: Launchpad

Attachments: XML File LPexportBug603750.xml    

 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



 Comments   
Comment by Philip Stoev (Inactive) [ 2010-07-10 ]

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?

Comment by Rasmus Johansson (Inactive) [ 2010-07-16 ]

Launchpad bug id: 603750

Generated at Thu Feb 08 06:43:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.