How TIMESTAMP() Works in MariaDB

In MariaDB, TIMESTAMP() is a built-in date and time function that returns a datetime value, based on its argument/s.

It can be used with either one argument or two, as follows:

  • When used with one argument, it returns that date or datetime expression as a datetime value.
  • When used with two arguments, it adds the second (time) argument to the first (date or datetime) expression, then returns the resulting datetime value.
Continue reading

How TIMEDIFF() Works in MariaDB

In MariaDB, TIMEDIFF() is a built-in date and time function that returns the difference between two time values or datetime values, expressed as a time value.

It’s similar to the DATEDIFF() function, except that DATEDIFF()‘s return value is expressed in days.

TIMEDIFF() accepts two arguments, both of which are time or datetime expressions. It then subtracts the second time from the first.

Continue reading

How SYSDATE() Works in MariaDB

In MariaDB, SYSDATE() is a built-in date and time function that returns the current date and time.

It returns the time that the function was executed (which could be different to the time that the statement was executed).

The return value is returned in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS.uuuuuu format, depending on whether the function is used in a string or numeric context.

The return value is expressed in the current time zone.

You also have the option of specifying the microsecond precision.

Continue reading