Welcome to MSDN Blogs Sign in | Join | Help

Microsoft Access Team Blog

Get product announcements, tips and tricks, and news directly from the team @ Microsoft.
Constructing Readable Time Elapsed Strings – MSDN article

There is a new article on MSDN that has some useful code samples. This was based off a post by Kerry Westphal on the Access blog a while back. Here is the intro:

Many Web 2.0 applications are designed to make it easy to visualize complex data. I found myself recently challenged with this task while working on a project where I wanted to display on a report to show the time elapsed between the current date and another date. Some example scenarios could include how much time has elapsed since a user profile has been updated, the time that remains until taxes are due, or how long a library book has been checked out. I did not just want to show the hours or even days elapsed, but something more in sync with the way I want the information given to me─specifically, that when dates are closer to the current date and time they are represented precisely, and dates and times that are farther away are shown generally. I wrote the ElapsedTime user-defined function to accomplish this task. The function can be used in a query to obtain a string that represents the time elapsed. The string returned is either specific or general depending on the length of time elapsed. For example, if the date is close to the current date, it appears as "In 12 hours, 27 minutes". If the date was long ago, it appears as, "A year ago". The following screen shot shows the results of the ElapsedTime function when it is used to track items in a calendar.

Report showing modern elapsed time string

http://msdn.microsoft.com/en-us/library/dd569711.aspx

Posted: Wednesday, March 25, 2009 4:35 PM by Clint Covington
Filed under: ,

Comments

Tony Toews - Access MVP said:

Nice stuff.  I've had vague thoughts of implementing such myself but it was way down on my roundtuit list.

Thanks, Tony

# March 26, 2009 2:28 AM

wrmosca said:

I would have added a second parameter instead of using Now(). And I changed the TimeStart to a variant so it won't blow up if the date being passed is null.

# March 30, 2009 11:58 AM

wrmosca said:

I should have said the TimeStart should be a variant because if a null date data type is passed it will be read as 00:00

# March 30, 2009 12:02 PM
New Comments to this post are disabled
Page view tracker