By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,261 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Need your help please. Covert time to army time, and trim off the date & am/pm

P: n/a
Option Explicit
Private mdTarget1 As Date
Private mdTarget2 As Date

' called on form load
Public Sub SetRecordStartTime()

mdTarget1 = DateAdd("n", 60, Time)
mdTarget2 = DateAdd("n", 120, Time)

End Sub

' I am using then using a if statement like "If Time mdTarget1 And
Time < mdTarget2 Then"
Everything is working until after 12 midnight and then it returns for
example something like "10/10/07 12:00:00 AM" .

Can you help me do the following:

1st: Covert time to army time (1-24);
2nd: Only show the time and not the date or am/pm;
Your help would be greatly appreciated!!!

Oct 10 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If you need to format your time in 24 hour formatting, use the formatting
string HH.mm.

firstTargetDate = DateAdd("n", 60, Time)
secondTargetDate = DateAdd("n", 2550, Time)

Dim test As String
test = secondTargetDate.ToString("HH.mm")

The test variable then equals "04.16" which is 2550 minutes from when I coded
it, but yes, it does take the new day into consideration and prepend that
to the front. Just as long as you realize it's the next date, you can cut
the date part off with custom ToStrings. You don't want to totally get rid
of the date component (behind the scenes, presentation is another case) because
it is needed for proper calculation--you don't want 2100-0300 span to the
next day.

HTH.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com
Option Explicit
Private mdTarget1 As Date
Private mdTarget2 As Date
' called on form load
Public Sub SetRecordStartTime()
mdTarget1 = DateAdd("n", 60, Time)
mdTarget2 = DateAdd("n", 120, Time)
End Sub

' I am using then using a if statement like "If Time mdTarget1 And
Time < mdTarget2 Then"

Everything is working until after 12 midnight and then it returns for
example something like "10/10/07 12:00:00 AM" .

Can you help me do the following:

1st: Covert time to army time (1-24);
2nd: Only show the time and not the date or am/pm;
Your help would be greatly appreciated!!!

Oct 10 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.