Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Algorithms
Expertise: Beginner
Mar 3, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Calculating time intervals

How does one calculate time differences. I know there's a function to calculate date differences.I am coding a database program which includes calculating the difference between a start time and a finish time.

Even though it is called the DateDiff function, it can be used to calculate up to second differences between two date/time values. All you have to do is change the first argument, which is the interval argument, to one of the following codes:

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of year
  • d - Day
  • w - Weekday
  • ww - Week
  • h - Hour
  • n - Minute
  • s - Second
You then add the remaining arguments of the DateDiff function and it will return the difference in the unit specified by the interval argument. Do a search for DateDiff in your Visual Basic help file for more details on how to use this function.
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date