Find The Day Difference Between Two Dates – Query Examples

Find The Day Difference Between Two Dates

To Find date difference between two dates, we must use the datediff function. The datediff function gets three parameters.

First Parameter: Date interval type. For day, we must write DD or day statement

Second Parameter: Small Date

Third Parameter: Older Date

 

Examples

EX 1) Calculate the day count between ‘09.05.2018’ and ‘10.05.2018’ dates;

Result : 30

Important Note: The result changes by the language of the sql server. To change sql server’s language type the code below;

New Result: 1 —Because in Turkish dateformat is day/month/Year in English Date Format is Month/Day/Year

 

EX 2) Calculate the day count between ‘09.05.2018’ and today; (English Format)

The Result: 191 (Date:’30.15.2019′);

EX3) Calculate the day count between student’s birthdate and today;

Result:

EX4) Calculate the day count between takendate and broughtDate on borrows table,

About the author

admin

Leave a Comment

%d bloggers like this: