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

#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.

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 
...

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

Greetings,

Tuukie.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.