format time

I have a form that displays time as:   10:00:00

I need to remove the seconds

I am using this value to display the time:  <%= (rs_appointment.Fields.Item("startime").Value) %>

This is my SQL:  

SELECT a.activityid, a.firmid, a.acttype, a.actname, a.actnote, a.blobid, a.partylist,a.actdesc,a.dateinitiated, a.processtep, a.lastmodified,a.complete,a.sent_by,a.responsible,a.Schdemailon,   b.caseid, b.alienid,  c.firstnm, c.lastnm, d.mailstr, d.maidenNm, convert(varchar(25), a.dateinitiated, 108) as startime, convert(varchar(25), a.lastmodified, 108) as endtime
FROM dbo.Activities a   left join cases as b on a.caseid = b.id  left join users as c on b.alienid = c.userid  left join users as d on a.responsible = d.userid
WHERE a.ActivityId = MMColParam and a.FirmId = MMColParam2



Help is appreciated.
LVL 1
AleksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
use the FormatDateTime() function:

<%= ( FormatDateTime( rs_appointment.Fields.Item("startime").Value), 4 ) %>
PortletPaulEE Topic AdvisorCommented:
to do this in the SQL, just limit the length of the varchar

by default style 108 gives hh:mm:ss

to get just hh:mm limit the length to 5 chars

convert(varchar(5), your_data_here ,108)

see: http://www.experts-exchange.com/articles/12315/SQL-Server-Date-Styles-formats-using-CONVERT.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
Didn't work:  <%= ( FormatDateTime( rs_appointment.Fields.Item("startime").Value), 4 ) %>

Error:  

Microsoft VBScript compilation  error '800a03ee'

Expected ')'

/BlueDot/Intranet/Calendar/Details.asp, line 309
Response.Write(( FormatDateTime( rs_appointment.Fields.Item("startime").Value), 4 ))
------------------------------------------------------------------------------^
Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Big MontyWeb Ninja at largeCommented:
to do this in the SQL, just limit the length of the varchar

don't think i agree with this approach, puts unnecessary strain (however small), on the database server, especially when there's a built in function available for use

i had a typo, try:

<%= ( FormatDateTime( rs_appointment.Fields.Item("startime").Value), 4 ) ) %>
PortletPaulEE Topic AdvisorCommented:
strain? yikes, the server would have to be less than a Samsung S3 to be affected by that.

I'm simply offering an alternative that will not strain the server. Note, the convert function is already used (and is necessary), all one is adding is a limit to the length of the varchar.

oh, and by the way, if you are using SQL Server 2012 or later you could (should?) achieve this using FORMAT() instead of convert() e.g.

FORMAT([YourTimeColumn],'mm:ss')

I have no problem at all formatting at the presentation layer, but it may suit to use the dbms.
AleksAuthor Commented:
Thanks to both !
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.