+---------------------+----------+---------------------+ | 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() . 

Because SYSDATE()  can return different values even within the same statement, and is not affected by SET TIMESTAMP , it is nondeterministic and therefore unsafe for replication if statement-based binary logging is used. If that is a problem, you can use row-based logging. 

Alternatively, you can use the --sysdate-is-now  option to cause SYSDATE()  to be an alias for NOW() . This works if the option is used on both the replication source server and the replica. 

The nondeterministic nature of SYSDATE()  also means that indexes cannot be used for evaluating expressions that refer to it. 

• TIME( expr ) 

Extracts the time part of the time or datetime expression expr  and returns it as a string. 

This function is unsafe for statement-based replication. A warning is logged if you use this function when binlog_format  is set to STATEMENT . 

mysql> SELECT TIME(’2003-12-31 01:02:03’); -> ’01:02:03’ mysql> SELECT TIME(’2003-12-31 01:02:03.000123’); -> ’01:02:03.000123’ 

• TIMEDIFF( expr1 , expr2 ) 

TIMEDIFF()  returns expr1 − expr2  expressed as a time value. expr1  and expr2  are time or date- and-time expressions, but both must be of the same type. 

The result returned by TIMEDIFF()  is limited to the range allowed for TIME  values. Alternatively, you can use either of the functions TIMESTAMPDIFF()  and UNIX_TIMESTAMP() , both of which return integers. 

mysql> SELECT TIMEDIFF(’2000:01:01 00:00:00’, -> ’2000:01:01 00:00:00.000001’); -> ’-00:00:00.000001’ mysql> SELECT TIMEDIFF(’2008-12-31 23:59:59.000001’, -> ’2008-12-30 01:01:01.000002’); -> ’46:58:57.999999’ 

• TIMESTAMP( expr ) , TIMESTAMP( expr1 , expr2 ) 

With a single argument, this function returns the date or datetime expression expr  as a datetime value. With two arguments, it adds the time expression expr2  to the date or datetime expression expr1  and returns the result as a datetime value. 

mysql> SELECT TIMESTAMP(’2003-12-31’); -> ’2003-12-31 00:00:00’ mysql> SELECT TIMESTAMP(’2003-12-31 12:00:00’,’12:00:00’); -> ’2004-01-01 00:00:00’ 

