Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

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

Posted on 2004-10-14
10
Medium Priority
?
460 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 400 total points
ID: 12312493
oops my mistake :)

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

capitalize it :)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

649 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