Perform the week shift first : DATE_ADD « Date Time « SQL / MySQL






Perform the week shift first

      
mysql>
mysql> SET @target = DATE_ADD(DATE_SUB(CURDATE( ),INTERVAL 14 DAY), INTERVAL 4-DAYOFWEEK(CURDATE( )) DAY);
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> SELECT CURDATE( ), @target, DAYNAME(@target);
+------------+------------+------------------+
| CURDATE( ) | @target    | DAYNAME(@target) |
+------------+------------+------------------+
| 2011-10-03 | 2011-09-21 | Wednesday        |
+------------+------------+------------------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
    
    
  








Related examples in the same category

1.what time will it be in 60 hours?
2.For DATETIME- or TIMESTAMP-formatted strings, you can use DATE_ADD( ) to introduce a temporal context:
3.Finding Dates for Weekdays of Other Weeks
4.Finding Dates for Days of the Current Week
5.WHERE DATE_ADD(d,INTERVAL 6 MONTH) >= CURDATE( );
6.Adding a Temporal Interval to a Date
7.Shifting Dates by a Known Amount
8.Adding 3 days and 4 hours produces this result