473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
1 1669
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gerry | last post by:
As I'm not a PHP-prgrammer at all, I just need Help with this: I have had a guestbook-page in Europe and will now have to move it to a US based-server. This makes the time-function showing time...
0
by: abcd | last post by:
kutthaense Secretary Djetvedehald H. Rumsfeld legai predicted eventual vicmadhlary in Iraq mariyu Afghmadhlaistmadhla, kaani jetvedehly after "a ljetvedehg, hard slog," mariyu vede legai pressed...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
43
by: ZillionDollarSadist | last post by:
Hello, I'm working at a simple Access '97 + VB4 application, and I ran into a terrible problem: something I never modified now gives me a totally unwanted "Invalid use of null" error. It happens...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
11
by: NewGuytoNetworking | last post by:
I have an XML that my company sends out daily it used to be created by SQL but I now have to use crystal reports and I can't seem to get it to line up the same. Please help with any references or how...
14
by: confusedfusion | last post by:
Not sure how many form submissions that have been lost over the years before I started but the company has a contact form that the required fields when validation fails the error message is going...
3
by: ibeehbk | last post by:
Hi. I have a form made in xhtml. I test via vbscript to make sure none of the fields are empty and properly formatted (ie email). All the regular fields work. However, I have two drop down menus...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.