Discussion Locked

Date Difference Between two given dates

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
How do we calculate the number of dates between two given dates (in the format dd/mm/yyyy)?

7 replies

by biftuk

Sorry, I was hoping to get the date difference between two give dates in dd/mm/yyyy format using visual basic 6.0

Thank you

by sl-campbell

Use the DateDiff function:
DateDiff(interval, date1, date2[, firstdayofweek[, firstweekofyear]])

"interval" is a required string. This determines in what interval the difference is calculated:

"yyyy" = year
"m" = Month
"d" = Day
"h" = hour
"n" = minute
"s" = Seconds

So, if you want to know the date difference in days between the first of the year and todays date use it as:

Debug.Print DateDiff("d","01/01/2002",Date())

This discussion is closed to new replies.