Question MS Access Time Input Mask

Mohsin Malik

Registered User.
Local time
Today, 08:08
Joined
Mar 25, 2012
Messages
179
Hello,

I have a field in my table where I could enter time, I have formatted the field as "Short Time" with date/time data type. I have added a Input Mask for the time with 00:00 so we could only type 1530 quickly and it would taken it as 15:30 time. As there are thousands of entries each day, I have a quick question for the time. If we have time 8:30 AM, we have to input 0830 and it would enter it as 08:30 and its little odd to first enter "0" and then 830, Is it possible we could only enter 830 and it will taken the time as 08:30 and the rest of the things works like the same as it is working right now.

Any Idea suggestions really appreciated.

Thank you
Mohsin
 
Does the user enter the current time? Or some other time?
How would you be certain that the user enters the correct time (whatever it is)--- users make typing errors.
I realize your example shoes 0830 and 1530 - do users work at say 8:30 PM (2030 but accidents happen)?
 
Dear Jdraw,

Thank you for the reply, User will enter different time and it is not current time, No its Morning 8:30 AM, 1530 works perfectly with input mask but we want to enter 830 instead of 08:30 (and its definately a morning time), Any Idea how to get this done?

Thanks
Mohsin
 
Do you have to do any arithmetic with the time value?
If not, then a simple function could work
Code:
Function TextToTime(Timein As Integer) As String
    Dim txtTime As String
    txtTime = CStr(Timein)
    If Len(txtTime) = 3 Then txtTime = "0" & txtTime
    TextToTime = Mid(txtTime, 1, 2) & ":" & Right(txtTime, 2)
End Function


If arithmetic is needed:
Access stores the data and time as a double. The part to the left of the . represents the days since 12/30/1899
the part to the right is the time.

From M$oft:
Valid time values range from .0 (00:00:00) to .99999 (23:59:59). The numeric value represents a fraction of one day. You can convert the numeric value to hours, to minutes, and to seconds by multiplying the numeric value by 24.

It might be easier to use 2 text boxes hr and min
then you could do some arithmetic
?(8 + 30/60)/24 to get = 0.354166666666667

and to get time
?Cvdate( 0.354166666666667)
8:30:00 AM

Just saying it's possible, not necessarily pretty.
 

Users who are viewing this thread

Back
Top Bottom