Finding out difference in two dates by using DateDiff function

We can find out the difference between two dates by using DateDiff function of VBScript used in ASP. DateDiff() finds out the difference of the dates based on the required date part like month, year, days etc. Here is the basic syntax of DateDiff function.
DateDiff(date_type, date1, date2, first_dow, first_woy)
Here date_type is the date part to be considered while returning the output. This can be month, day, year etc. The table with different values of date_type is listed at the end. Next two arguments date1 and date2 are two date values for which difference is to be calculated. The other two arguments first_dow and first_woy are optional arguments. First_dow takes the value to specify what is to be taken as first day of the week and the other value first_woy takes the value of first week of the year.

Let us see this example code on uses of DateDiff to find out difference in months between two dates.
Dim d_diff
Response.Write "Today date is " & d_today & "<br>"
Response.Write "Difference  " & d_diff & "<br>"
The output of the above by changing the value of date_type we can find out the difference in days, years, weeks etc. Table for different date_type values
"ww"Week of the year

Be the first to post comment on this article :

Post your comments , suggestion , error , requirements etc here .

We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2023 All rights reserved worldwide Privacy Policy Disclaimer