Solved

converting time field to integer

Posted on 2000-05-12
10
240 Views
Last Modified: 2010-05-02
I am taking a field from Access (short time format) and I need to convert it to an integer (number of seconds past midnight)
I understand the idea of getting the hour, mutiplying it by number of seconds in an hour and then adding that to number of seconds in the minutes.

But how do I get that hour value and that minute value

0
Comment
Question by:Diehl
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805932
Hour(Now)
Minute(Now)
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805936
The Hour is in 24-hour time.
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805942
Whole thing:

SecondsSinceMidnight = (Hour(Now) * 3600) + (Minute(Now) * 60) + seconds(Now)
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805948
SecondsSinceMidnight = (Hour(Now) * 3600) + (Minute(Now) * 60) + Second(Now)
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 2805954
Note that if you want seconds, as shown above, there are 86,400 seconds in a day, so you won't be able to store that in an integer (will require a long).
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Diehl
ID: 2805955
what is the 'now'
is that current time?
How do I read the hour and min from the database?
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2805968
how are you reading the field in?  does it display in military time or AM:PM time?
0
 

Author Comment

by:Diehl
ID: 2805981
The access database is formated in short time:
1:45
14:52
3:15
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 2805989
in that case then you just need to parse the string

Dim hour As String
Dim minute As String
Dim pos As Long

pos = Instr(1,"field",":")
hour = Left("field",pos - 1)
minute = Right("field", 2)
0
 
LVL 32

Expert Comment

by:bhess1
ID: 2806049
You can use the code from above with your field:

SecondsSinceMidnight = (Hour(rs.MyTime) * 3600) + (Minute(rs.MyTime) * 60) + seconds(rs.MyTime)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 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

23 Experts available now in Live!

Get 1:1 Help Now