Diehl
asked on
converting time field to integer
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
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
The Hour is in 24-hour time.
Whole thing:
SecondsSinceMidnight = (Hour(Now) * 3600) + (Minute(Now) * 60) + seconds(Now)
SecondsSinceMidnight = (Hour(Now) * 3600) + (Minute(Now) * 60) + seconds(Now)
SecondsSinceMidnight = (Hour(Now) * 3600) + (Minute(Now) * 60) + Second(Now)
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).
ASKER
what is the 'now'
is that current time?
How do I read the hour and min from the database?
is that current time?
How do I read the hour and min from the database?
how are you reading the field in? does it display in military time or AM:PM time?
ASKER
The access database is formated in short time:
1:45
14:52
3:15
1:45
14:52
3:15
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use the code from above with your field:
SecondsSinceMidnight = (Hour(rs.MyTime) * 3600) + (Minute(rs.MyTime) * 60) + seconds(rs.MyTime)
SecondsSinceMidnight = (Hour(rs.MyTime) * 3600) + (Minute(rs.MyTime) * 60) + seconds(rs.MyTime)
Minute(Now)