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,

2 Comments

  • Hi, Just a slight correction
    You state above

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

    In fact, day/month/year is the common format in Europe, and is definitely the preferred format in the UK (AKA as “England”). The month/day/year format is the format favoured in North America

    Best regards

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: