The author has given his source code to reproduce the datediff function by accepting the system time. The main function of this article is to calculate the number of intervals between two consecutive dates. This article determines how many specified time intervals exist between any two dates. If we need the intervals in weeks then it is also possible. Even it could show you how many sundays are there between the two dates which you like to check.