Solved

displaying a time without the seconds.

Posted on 2008-10-01
2
212 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 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