In order to know the variation amid the 2 days, DATEDIFF is used. It can perform its role in SQL Server and MYSQL. But the structure is not same in these databases. Here, we are going to explain the structure separately in the two databases;
The practice of DATEDIFF in the database MYSQL is given below;
Here, the type of data can be DATETIME or DATE. The product is expression2 – expression3.
Here is an example using SQL:
The product is given below;
The answer is that 2011-01-11 is 6 days subsequent to 2011-01-05.
2- SQL Server:-
The function of DATEIFF in SQL is given below;
Here, the type of data can be time, datetime or date. The product will be expression3 – expression2.
ISO_WEEK isowk, isoww
Quarter Qq, q
Month mm, m
Dayofyear Dy, y
Day Dd, d
Week Wk, ww
Minute Mi, n
Second ss, s
Here is an example from SQL:-
The product will be as follows:
The reason is that the date 2011-01-05 is 6 days prior to 2011-01-11.