Skip to content
Advertisement

Check datatype of column after applying function MySQL

I want to know datatype of column after using a function.

SELECT timediff(date('2020-10-01 00:00:00'), date('2020-10-00 00:00:00'));

After using timediff function what datatype is it? I’ve looked at the doc to search for output datatype of a function https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html but could not find, Also it would be inefficient to memorize which function outputs what datatype, so I would like to perform an operation creating new column and know its exact datatype.

When I connect MySQL to python and check its datatype it is timedelta but is it also called timedelta in MySQL?

Advertisement

Answer

After using timediff function what datatype is it? I’ve looked at the doc to search for output datatype of a function but could not find.

Well, the documentation sure gives you the answer (emphasis mine):

TIMEDIFF() returns expr1 − expr2 expressed as a time value.

And further:

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.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement