Solved

"1:00 PM" or "1:00 AM" to change to military time?

Posted on 2004-10-14
10
422 Views
Last Modified: 2010-05-18
How do I change the AM or PM to military time?

strMytime = "2:00 PM"

strNewTime = Format(CDate(strMytime), "hh:mm")      ' this only changes it to 2:00 not 14:00

THANKS
0
Comment
Question by:sticar
  • 5
  • 3
  • 2
10 Comments
 
LVL 1

Expert Comment

by:VBtorment
ID: 12311732
Format$(CDate(strTime),"h:mm")
0
 

Author Comment

by:sticar
ID: 12311770
Hmm... still says 2:00
0
 
LVL 1

Assisted Solution

by:VBtorment
VBtorment earned 100 total points
ID: 12312493
oops my mistake :)

Format$(CDate(strTime),"HH:MM")

capitalize it :)
0
 

Author Comment

by:sticar
ID: 12312589
Ahhh... much better.  Any idea why it would show:
14:01 instead of 14:00?
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12312684
NameSpace Microsoft.VisualBasic

MyStr = Format(MyDateTime, "hh:mm:ss tt")   ' Returns "05:04:23 PM".
MyStr = Format(MyDateTime, "HH:mm:ss")   ' Returns "17:04:23"

GL
0
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.

 
LVL 10

Accepted Solution

by:
Hans Langer earned 150 total points
ID: 12312694
Upss..
Dim MyDateTime As Date = #1/27/2001 5:04:23 PM#
MyStr = Format(MyDateTime, "hh:mm:ss tt")   ' Returns "05:04:23 PM".
MyStr = Format(MyDateTime, "HH:mm:ss")   ' Returns "17:04:23"

0
 

Author Comment

by:sticar
ID: 12312737
I'm only formating a string.

Dim strMyTime As String = Format(CDate("1:00 PM"),"HH:MM"))

Comes out "13:00"
0
 

Author Comment

by:sticar
ID: 12312741
Oops,
Comes out "13:01", suppose to be "13:00"
0
 

Author Comment

by:sticar
ID: 12312932
Ahhh... I just noticed it's a lowercase "mm".... THANKS!!!!
0
 
LVL 10

Expert Comment

by:Hans Langer
ID: 12312944
Format(CDate("1:00 PM"), "HH:mm")
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
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…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

707 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

16 Experts available now in Live!

Get 1:1 Help Now