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()
returnsexpr1 − expr2
expressed as atime
value.
And further:
The result returned by
TIMEDIFF()
is limited to the range allowed forTIME
values. Alternatively, you can use either of the functionsTIMESTAMPDIFF()
andUNIX_TIMESTAMP()
, both of which return integers.