DateDiff() between two dates in Classic ASP

DateDiff() returns how many specified interval boundaries occur between two Date values. Choose the interval carefully: a year result counts year boundaries, while a day result counts day boundaries.

Syntax

DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

The last two arguments are optional and matter mainly for calculations involving weeks.

Difference in months

Dim d_diff
d_diff = DateDiff("m", #2/28/2003#, #2/28/2006#)
Response.Write "Difference in months: " & d_diff
Boundary-counting note: DateDiff("yyyy",...) can return 1 when two dates are only a day apart but fall in different calendar years. Use the interval that matches the question you are answering.

DateDiff interval codes

IntervalMeaning
yyyyYear
qQuarter
mMonth
y / dDay
wWeekday boundary
wwCalendar week
hHour
nMinute
sSecond

ASP Home






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