Solved

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

Posted on 2004-10-14
10
448 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
[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
  • 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
Industry Leaders: 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!

 

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
 
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

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

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