Link to home
Start Free TrialLog in
Avatar of Stefan Motz
Stefan MotzFlag for United States of America

asked on

Is there a way to format the vbLongTime without displaying the seconds?

The code below returns the time from SQL Server database.

<%=FormatDateTime(rs("TimeCompleted"),vbLongTime)%>

I get: 12:47:00 PM

I would like: 12:47 PM

Thanks for your help.
Avatar of Wayne Michael
Wayne Michael
Flag of United States of America image

Maybe

rs("TimeCompleted").toString("hh:mm")
Here is the msdn article on custom formats

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Avatar of Stefan Motz

ASKER

I've tried it and this is the error I get:
Object doesn't support this property or method: 'toString'
Maybe because my page is written in Classic ASP
SOLUTION
Avatar of Om Prakash
Om Prakash
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of clockwatcher
clockwatcher

I suppose if you included the trailing space in the replace, you'd be fine:

replace(FormatDateTime(rs("TimeCompleted"),vbLongTime),":00 "," ")

But it would only work if you always had 00 seconds in your field as om_prakash_p mentioned.
In classic asp then I think just format(string,"HH:MM") works well.
Both methods work for me, thank you very much for your help.
The seconds are always 00, so I don't need to display them
See this for vb6 style format that should work with classic asp

http://www.vb6.us/tutorials/formating-dates-and-times-vb6