SQL date difference

How can I get the number of seconds between NOW () and the date in the database.

Thank.

+3
source share
2 answers

Use the function TIMESTAMPDIFF. (function TIMEDIFFhas an upper limit 838:59:59)

SELECT TIMESTAMPDIFF(SECOND, DateColumn, NOW()) As Seconds
FROM table
+4
source

Try the following:

SELECT TIME_TO_SEC(TIMEDIFF(Now(), yourDateTime)) From Table;
+3
source

Source: https://habr.com/ru/post/1793176/


All Articles