Function to Make Now dates Sortable in Listviews, etc.
Category:Dates and Math
Author:Micihael M. Ross
Version Compatibility: Visual Basic 6, Visual Basic 5
Str(Now) gives you a date and time according to your system settings. The problem is this date/time string does not sort in controls like Listviews. This function simply adds zeros to single-digit months, days and hours, and replaces AM and PM with the 24-hour clock. If you want sortable dates and times without using reams of complex code to add this behavior to the control, this is the way to go.
Instructions: Copy the declarations and code below and paste directly into your VB project.