0

I have a query which works in MYSQL 5, but doesn't work in MYSQL 4.. anybody ??

SELECT DATE_FORMAT(DATE_ADD(DATE_ADD(CURDATE(), INTERVAL 0 - '52' WEEK), INTERVAL 2 - DAYOFWEEK(CURDATE()) DAY), '%v') as date, DATE_FORMAT(DATE_ADD(DATE_ADD(CURDATE(), INTERVAL 0 - '52' WEEK), INTERVAL 2 - DAYOFWEEK(CURDATE()) DAY), '%Y%v') as date_ordered
2
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by tuukie
0

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WEEK), INTERVAL 2 - DAYOFWEEK(CURDATE()) DAY), '%v') as date, DATE_FORMAT(DATE_A' at line 1

The problem is at the interval 0-'52' WEEK. Change this to 364 DAYS it works, but then I don't get the right info.

0

That is the WEEK function. You are using the INTERVAL function with the WEEK part. I see this:

The INTERVAL keyword and the unit specifier are not case sensitive. 

The following table shows the expected form of the expr argument for each unit value. 

unit Value  Expected expr Format  Version 
MICROSECOND MICROSECONDS 4.1.1 
SECOND SECONDS Pre-4.1 
MINUTE MINUTES Pre-4.1 
HOUR HOURS Pre-4.1 
DAY DAYS Pre-4.1 

WEEK   WEEKS   5.0.0 

MONTH MONTHS Pre-4.1 
QUARTER QUARTERS 5.0.0 
YEAR YEARS Pre-4.1 
...
0

Thanx, for the info, now I can stop looking!

Greetings,

Tuukie.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.