Solved

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

Posted on 2004-10-14
10
425 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

863 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

22 Experts available now in Live!

Get 1:1 Help Now