+---------------------+----------+---------------------+ | SYSDATE() | SLEEP(2) | SYSDATE() | +---------------------+----------+---------------------+ | 2006-04-12 13:47:44 | 0 | 2006-04-12 13:47:46 | +---------------------+----------+---------------------+ 

In addition, the SET TIMESTAMP  statement affects the value returned by NOW()  but not by SYSDATE() . This means that timestamp settings in the binary log have no effect on invocations of SYSDATE() . Setting the timestamp to a nonzero value causes each subsequent invocation of NOW()  to return that value. Setting the timestamp to zero cancels this effect so that NOW()  once again returns the current date and time. 

See the description for SYSDATE()  for additional information about the differences between the two functions. 

• PERIOD_ADD( P , N ) 

Adds N  months to period P  (in the format YYMM  or YYYYMM ). Returns a value in the format YYYYMM . 

mysql> SELECT PERIOD_ADD(200801,2); -> 200803 

• PERIOD_DIFF( P1 , P2 ) 

Note 

The period argument P  is not  a date value. 

Returns the number of months between periods P1  and P2 . P1  and P2  should be in the format YYMM  or YYYYMM . Note that the period arguments P1  and P2  are not  date values. 

mysql> SELECT PERIOD_DIFF(200802,200703); -> 11 

• QUARTER( date ) 

Returns the quarter of the year for date , in the range 1  to 4 . 

mysql> SELECT QUARTER(’2008-04-01’); -> 2 

• SECOND( time ) 

Returns the second for time , in the range 0  to 59 . 

mysql> SELECT SECOND(’10:05:03’); -> 3 

• SEC_TO_TIME( seconds ) 

Returns the seconds  argument, converted to hours, minutes, and seconds, as a TIME  value. The range of the result is constrained to that of the TIME  data type. A warning occurs if the argument corresponds to a value outside that range. 

mysql> SELECT SEC_TO_TIME(2378); -> ’00:39:38’ mysql> SELECT SEC_TO_TIME(2378) + 0; -> 3938 

• STR_TO_DATE( str , format ) 

