WEEK
Stai visualizzando una vecchia versione di questo article. Visualizza
la versione più recente.
Sintassi
WEEK(data[, modalità])
Spiegazione
This function returns the week number for date. The two-argument form of
WEEK()
allows you to specify whether the week starts on Sunday or Monday
and whether the return value should be in the range from 0 to 53 or from 1 to
53. If the mode argument is omitted, the value of the default_week_format
system variable is used.
Examples:
MariaDB [(none)]> SELECT WEEK('2008-02-20'); +--------------------+ | WEEK('2008-02-20') | +--------------------+ | 7 | +--------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> SELECT WEEK('2008-02-20',0); +----------------------+ | WEEK('2008-02-20',0) | +----------------------+ | 7 | +----------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> SELECT WEEK('2008-02-20',1); +----------------------+ | WEEK('2008-02-20',1) | +----------------------+ | 8 | +----------------------+ 1 row in set (0.00 sec) MariaDB [(none)]> SELECT WEEK('2008-12-31',0); +----------------------+ | WEEK('2008-12-31',0) | +----------------------+ | 52 | +----------------------+ 1 row in set (0.05 sec) MariaDB [(none)]> SELECT WEEK('2008-12-31',1); +----------------------+ | WEEK('2008-12-31',1) | +----------------------+ | 53 | +----------------------+ 1 row in set (0.00 sec) MariaDB [(none)]>
CREATE TABLE t1 (d DATETIME); INSERT INTO t1 VALUES ("2007-01-30 21:31:07"), ("1983-10-15 06:42:51"), ("2011-04-21 12:34:56"), ("2011-10-30 06:31:41"), ("2011-01-30 14:03:25"), ("2004-10-07 11:19:34");
MariaDB [test]> SELECT d, WEEK(d,0), WEEK(d,1) from t1; +---------------------+-----------+-----------+ | d | WEEK(d,0) | WEEK(d,1) | +---------------------+-----------+-----------+ | 2007-01-30 21:31:07 | 4 | 5 | | 1983-10-15 06:42:51 | 41 | 41 | | 2011-04-21 12:34:56 | 16 | 16 | | 2011-10-30 06:31:41 | 44 | 43 | | 2011-01-30 14:03:25 | 5 | 4 | | 2004-10-07 11:19:34 | 40 | 41 | +---------------------+-----------+-----------+ 6 rows in set (0.00 sec)
Commenti
Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.