Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

want to input time 24:00 but appear 00:00

Status
Not open for further replies.

budich

Programmer
Oct 7, 2000
79
0
0
ID
Hi Guys,

Does anyone know how to format a field so can receive time 24:00 (12:00 pm).
Basically, I make a form that can receive time in and time out of heavy equipment.
For example time in = 19:00 and time out 24:00, and I have another field to calculate the duration between them. So duration should be = 24:00 - 19:00 = 5 hours.

However, what I found in the field appear 00:00 and it calculate as 12:00 am, so not 5 hours but 17 hours !!!

Thank you in advance
Budi
 
Without getting into the details, one wonders what you would expect to derive if the equipment were returned late? (perhaps att one AM?) If you think your way through this and resolve it, the earli0er tome should not be an issue.


Hint use the ubiquitous {F1} (aka help) and check on Date/Time data type as well as the various Date functions (DateAdd, DateDiff, DatePart, ... )








MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
2003-01-1 00:00:00 start of day
2003-01-1 23:59:59 end of day

There is no 24:00:00, as 24:00:00 is the new day with a start time of 00:00:00.

So 2003-01-1 23:59:59 + 1 second =

2003-01-2 00:00:00 start of new day

Besides if you need to store times that are more than 2 calendar days you should use datetime, and not just time. What if you decide later you want to hire things out over the week etc?
 
I use this function I created for times.

Public Function DiffTime(TimeIN, TimeOUT)
Dim msg As String
Dim Hr1, Mn1, SS1, Hr2, Mn2, SS2, Mint As Variant
Dim DiffTime2
On Error GoTo Errhand

If IsNull(TimeIN) Then
msg = "You did not punch IN yet" & Chr$(10)
MsgBox msg & "Please do so"
GoTo ExitMe:
End If
'debug.print "Time IN "; TimeIN, "TimeOut "; TimeOUT
Hr1 = DatePart("h", TimeIN)
Mn1 = DatePart("n", TimeIN)
SS1 = DatePart("s", TimeIN)
Hr2 = DatePart("h", TimeOUT)
Mn2 = DatePart("n", TimeOUT)
SS2 = DatePart("s", TimeOUT)

DiffTime2 = TimeSerial(Hr2 - Hr1, Mn2 - Mn1, SS2 - SS1)
'debug.print "DiffTime2 "; DiffTime2
If DiffTime2 < &quot;1:00 AM&quot; Then
'debug.print DiffTime2
Mint = DatePart(&quot;n&quot;, DiffTime2)
If Len(Mint) = 1 Then Mint = &quot;0&quot; & Mint
DiffTime2 = &quot;00:&quot; & Mint & &quot;:&quot; & DatePart(&quot;s&quot;, DiffTime2)
DiffTime = DiffTime2
Else
DiffTime = Format(DiffTime2, &quot;HH:MM:SS&quot;)
End If
'debug.print &quot;DiffTime > &quot;; DiffTime

ExitMe:
Exit Function

Errhand:
Select Case Err.Number
Case 94
' Invalid use of null
MsgBox &quot;You did not punch in&quot;
Case Else
MsgBox Err.Number & &quot; &quot; & Err.Description
Resume ExitMe
End Select
End Function

DougP, MCP
 
Thank you very much for your help, I am sorry reply to all of you very late.
For Michael Red & Jamfool, I realize that the equipment can be returned after 00:00 and the problem the computer recoqnise 00:00 as 12:00 the next day. And I have give data type DATE/TIME with Format in form SHORT TIME, but it won't work.
FOr Doug, Thank you for your function, I will try your function after this. Hope can solve my problem.
thank you very much for all of you
regards
Budi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top