MySQL/日期:修订间差异
来自康健生活
| 第109行: | 第109行: | ||
| 获取某周的周日 | | 获取某周的周日 | ||
| class="td-pre-noborder" style="padding:0;" | <syntaxhighlight lang="mysql">select date_sub('2026-01-23',INTERVAL WEEKDAY('2026-01-23') - 6 DAY);</syntaxhighlight> || || | | class="td-pre-noborder" style="padding:0;" | <syntaxhighlight lang="mysql">select date_sub('2026-01-23',INTERVAL WEEKDAY('2026-01-23') - 6 DAY);</syntaxhighlight> || || | ||
|- | |||
| 查询本周数据 | |||
| class="td-pre-noborder" style="padding:0;" | <syntaxhighlight lang="mysql">SELECT * FROM table_name WHERE WEEK(date_column) = WEEK(CURDATE()) AND YEAR(date_column) = YEAR(CURDATE());</syntaxhighlight> || || | |||
|} | |} | ||