Bug #24956 default_week_format does not affect yearweek()
Submitted: 11 Dec 2006 14:08 Modified: 28 Sep 2010 14:06
Reporter: Samuel Zayas Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S4 (Feature request)
Version:5.0.22-community-nt OS:Windows (Windows XP)
Assigned to: CPU Architecture:Any
Tags: default_week_format, week, year, yearweek

[11 Dec 2006 14:08] Samuel Zayas
Description:
The dynamic variable default_week_format doesn't affect the datetime function yearweek(). It seems the default mode of yearweek is 2. The behaviour doesn't quite feel logical as the functions are very close.

How to repeat:
set global default_week_format=0;
select week("2001-01-01"), yearweek("2001-01-01");

returns:
0, 200053

set global default_week_format=2;
select week("2001-01-01"), yearweek("2001-01-01");

returns:
53, 200053

set global default_week_format=5;
select week("2001-01-01"), yearweek("2001-01-01");

returns:
1, 200053

Suggested fix:
The default_week_format variable could affect yearweek() aswell as week().

The possibility to pass the mode to the yearweek(date,[mode]) function is used as a workaround for now.

select yearweek("2001-01-01",5);
returns 200101 as expected.
[14 Dec 2006 16:27] Hartmut Holzgraefe
Verified, filed as feature request.
[28 Sep 2010 14:06] Mattias Jonsson
Closing as duplicate of bug#30454.