The number of seconds between dates that lie two weeks apart can be computed like this: : UNIX_TIMESTAMP « Date Time « SQL / MySQL






The number of seconds between dates that lie two weeks apart can be computed like this:

    
mysql>
mysql> SET @dt1 = '1984-01-01 09:00:00';
Query OK, 0 rows affected (0.00 sec)

mysql> SET @dt2 = '1984-01-15 09:00:00';
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT UNIX_TIMESTAMP(@dt2) - UNIX_TIMESTAMP(@dt1) AS seconds;
+---------+
| seconds |
+---------+
| 1209600 |
+---------+
1 row in set (0.00 sec)

mysql>

   
    
    
    
  








Related examples in the same category

1.UNIX_TIMESTAMP calculation
2.UNIX_TIMESTAMP( ) can convert DATE values to seconds.
3.Converting Between Date-and-Time Values and Seconds
4.To convert the interval in seconds to other units, perform the appropriate arithmetic operation.