SQL DATETIME FUNCTION DATEDIFF | How to calculate the difference between two date values in SQL

preview_player
Показать описание
#DATEDIFF--the DATEDIFF function returns the difference between two date values, based on the interval specified
According to the documentation for MariaDB DATEDIFF only takes two arguments:
DATEDIFF() returns (expr1 – expr2) expressed as a value in days from one date to the other. expr1 and expr2 are date or date-and-time expressions.
Only the date parts of the values are used in the calculation.

You can follow us on the below social media handles:-
Рекомендации по теме
Комментарии
Автор

Hey there, glad to meet again.
I learned about timestamp as a date data type.
My question is, if i where to record timestamps of every record entered into the database. Would the sql server generate two identical timestamps given the records where run simultaneously..is that case a hypothetical one or would it happen?
Thanks for taking care of this.

hasanmougharbel
Автор

how do i select all records that have an event datetime witin 1 hour before, for example mysql select all that time_diff less than 1 hour from datetime? its for a reminder email i want to make on a cronjob can you help with this sql query?

JNET_Reloaded