possible curdate() issue

possible curdate() issue

am 01.10.2010 16:46:36 von Ted Maas

This is most likely user error but I noticed today that
when I subract 1 from the curdate() function I get a very
interesting result:

mysql> select curdate() - 1 from dual;
+---------------+
| curdate() - 1 |
+---------------+
| 20101000 |
+---------------+
1 row in set (0.00 sec)


curdate() itself is OK:

mysql> select curdate() from dual;
+------------+
| curdate() |
+------------+
| 2010-10-01 |
+------------+
1 row in set (0.00 sec)


These also seem somewhat strange:

mysql> select curdate() - 70 from dual;
+----------------+
| curdate() - 70 |
+----------------+
| 20100931 |
+----------------+
1 row in set (0.00 sec)

mysql> select curdate() - 71 from dual;
+----------------+
| curdate() - 71 |
+----------------+
| 20100930 |
+----------------+
1 row in set (0.00 sec)


I use the curdate() - 1 to pick up yesterdays date from an index.
On Sept. 30 the code worked OK. Today ... not so much.

Since this behavior is the same on MySQL 4.1.22, 5.0.77 and 5.1.36
I must be doing something wrong.


Any Ideas?

Ted Maas
Research Programmer
Systems Group
Academic Computing and Communications Center
University of Illinois at Chicago




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

RE: possible curdate() issue

am 01.10.2010 19:14:00 von Gavin Towey

You're using incorrect syntax for date math. Use:

CURDATE() - INTERVAL 1 day

See the manual for details.

-----Original Message-----
From: Ted Maas [mailto:tmaas@uic.edu]
Sent: Friday, October 01, 2010 7:47 AM
To: mysql@lists.mysql.com
Subject: possible curdate() issue

This is most likely user error but I noticed today that
when I subract 1 from the curdate() function I get a very
interesting result:

mysql> select curdate() - 1 from dual;
+---------------+
| curdate() - 1 |
+---------------+
| 20101000 |
+---------------+
1 row in set (0.00 sec)


curdate() itself is OK:

mysql> select curdate() from dual;
+------------+
| curdate() |
+------------+
| 2010-10-01 |
+------------+
1 row in set (0.00 sec)


These also seem somewhat strange:

mysql> select curdate() - 70 from dual;
+----------------+
| curdate() - 70 |
+----------------+
| 20100931 |
+----------------+
1 row in set (0.00 sec)

mysql> select curdate() - 71 from dual;
+----------------+
| curdate() - 71 |
+----------------+
| 20100930 |
+----------------+
1 row in set (0.00 sec)


I use the curdate() - 1 to pick up yesterdays date from an index.
On Sept. 30 the code worked OK. Today ... not so much.

Since this behavior is the same on MySQL 4.1.22, 5.0.77 and 5.1.36
I must be doing something wrong.


Any Ideas?

Ted Maas
Research Programmer
Systems Group
Academic Computing and Communications Center
University of Illinois at Chicago




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgtowey@ffn.com


This message contains confidential information and is intended only for the=
individual named. If you are not the named addressee, you are notified th=
at reviewing, disseminating, disclosing, copying or distributing this e-mai=
l is strictly prohibited. Please notify the sender immediately by e-mail i=
f you have received this e-mail by mistake and delete this e-mail from your=
system. E-mail transmission cannot be guaranteed to be secure or error-fre=
e as information could be intercepted, corrupted, lost, destroyed, arrive l=
ate or incomplete, or contain viruses. The sender therefore does not accept=
liability for any loss or damage caused by viruses or errors or omissions =
in the contents of this message, which arise as a result of e-mail transmis=
sion. [FriendFinder Networks, Inc., 220 Humbolt court, Sunnyvale, CA 94089,=
USA, FriendFinder.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg