Format Date To HH:MM AMPM Format in ASP
Category:Dates and Math
Version Compatibility: ASP, Visual Basic Script
Pre-.NET ASP ("classic ASP") supports the function FormatDateTime() but not Format(), which is available in VB 5 or 6. Compared with Format(), ASP's FormatDateTime() is very limited. If you want to display the time in the form HH:MM:SS AMPM, then you'd use FormatDateTime(date,3). However if you just want to display the time in HH:MM AMPM format, you have to parse the returned string from FormatDateTime(date,3) to get rid of the :SS portion. This is dumb. So I made an ASP snippet that creates a time string in HH:MM AMPM format. It's easily converted to a function but I will let you do that.
Instructions: Copy the declarations and code below and paste directly into your VB project.