我想检查startdate或enddate是否在上周。我想显示commRunStart或commRunEnd日期在上周的行。
SELECT A.commRunStart, A.commRunEnd FROM `commRuns` AS A
WHERE A.commRunStart >= CURDATE( ) - INTERVAL DAYOFWEEK( CURDATE( ) ) +6 DAY
OR A.commRunEnd < CURDATE( ) - INTERVAL DAYOFWEEK( CURDATE( ) ) -1 DAY
答案 0 :(得分:3)
SELECT A.commRunStart, A.commRunEnd FROM `commRuns` AS A
WHERE (A.commRunStart >= CURDATE( ) - INTERVAL DAYOFWEEK( CURDATE( ) ) +6 DAY
AND A.commRunStart < CURDATE( ) - INTERVAL DAYOFWEEK( CURDATE( ) ) -1 DAY )
OR (A.commRunEnd >= CURDATE( ) - INTERVAL DAYOFWEEK( CURDATE( ) ) +6 DAY
AND A.commRunEnd < CURDATE( ) - INTERVAL DAYOFWEEK( CURDATE( ) ) -1 DAY )