Solved

Changing the hour display

Posted on 2007-03-21
2
156 Views
Last Modified: 2010-04-23
Hi there,
How can i format the time in VS 2005?
right now i have the time display as 4:35 pm but i need instead to show 16::35pm
Thanks
0
Comment
Question by:jsctechy
  • 2
2 Comments
 
LVL 14

Accepted Solution

by:
jake072 earned 500 total points
ID: 18767187
Use:

DateTime.ToString("t")

That will result in 16:35.

It will not include pm, as that information is redundant...  If you need to include pm, then

DateTime.ToString("t") & CStr(IIf(DateTime.Now > 12, "pm", "am"))

You can also use DateTime.ToString("T") to display the seconds as well.

Jake
0
 
LVL 14

Expert Comment

by:jake072
ID: 18767190
NOTE: DateTime is a DateTime variable :)

If you want the current time, repleace DateTime with DateTime.Now.

Jake
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

709 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now