For an interval in weeks, do the same thing and divide the result by seven : TO_DAYS « Date Time « SQL / MySQL






For an interval in weeks, do the same thing and divide the result by seven

    
mysql>
mysql> SELECT (TO_DAYS('1884-01-01') - TO_DAYS('1883-06-05')) / 7 AS weeks;
+---------+
| weeks   |
+---------+
| 30.0000 |
+---------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
  








Related examples in the same category

1.TO_DAYS( ) can convert DATETIME or TIMESTAMP values to days, if you don't mind having it chop off the time par
2.If you pass TO_DAYS( ) a date-and-time value, it extracts the date part and discards the time.
3.Using two date-and-time values that lie a week apart
4.TO_DAYS( ) converts a date to the corresponding number of days
5.Calculating Intervals Between Dates