Grid View time format - hide seconds

Hi Experts,

This is one of those irritating things that I've never found a solution to. I'm using a grid view to display some sql data including a 'time (7)' field, by default this displays as hh:mm:ss. I'd like to hide the :ss part.

I have tried a couple of methods but neither have any impact:

Text='<%# Bind("otEnd","{0:HH:mm}") %>'

DataFormatString="{0:t}

In both the above examples the time continues to display in the format hh:mm:ss (grrrr) anyone...?
forstersAsked:
Who is Participating?
 
Lokesh B RDeveloperCommented:
Hi,

Convert the time(7) column to datetime in your SELECT query and use the format string in gridview.

SELECT CAST(otEnd AS datetime)  AS otEnd

 DataFormatString="{0:t}"

Or

Text='<%# Bind("otEnd","{0:HH:mm}") %>'
0
 
forstersAuthor Commented:
Thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.