Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

displaying a time without the seconds.

Posted on 2008-10-01
2
Medium Priority
?
216 Views
Last Modified: 2009-07-29
I have the following:
litEndTime.Text = _endTime.TimeOfDay.ToString

where _endTime is of datatype Date.

When this is displayed i get:
16:22:01.4715497

i want:
16:22

how can i do this?
0
Comment
Question by:scm0sml
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Expert Comment

by:copyPasteGhost
ID: 22615748
litEndTime.Text = _endTime.TimeOfDay.ToString("HH:mm")
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 22616267
TimeOfDay() returns a TimeSpan instance which does NOT accept formatting options for ToString()...   =\

Just use ToString() directly on your DateTime like this:

    litEndTime.Text = _endTime.ToString("HH:mm")
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question