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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Military Time

Status
Not open for further replies.

Dickx

Technical User
Aug 24, 2001
33
US
Is it possible to enter a time as a short time, and on field exit, convert the display to military (24 hour) time.
 
YES!

but firstly, a question.

do they enter am or pm when entering the time?


Program Error
Programmers do it one finger at a time!
 
How are ya Dickx . . . . .

Unless I'm missing something, [blue]Short Time is Military 24 hour time.[/blue] As long as you enter a proper time [blue]hh:mm[/blue] with/without [blue]am/pm[/blue] the display is coerced properly.

Just set the form to [blue]Short Time[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
AceMan1

Thank you. Follow up question What would the code be to calculate the time difference in minutes between time1 and time2 if for example, time1 = 1900 (7:00 pm) and 0700 (7:00am) Should be 720 minutes

Dickx
 
Dickx . . . . .
Code:
[blue]   = Abs(DateDiff("n", Me!Time1, Me!Time2))[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thank you again Aceman1 The code worked except one problem. If I enter 2300 (1100PM)as time1,then 0100 (1:00 AM)as time2, I get the elapsed time as 1320 minutes instead of 120 minutes. How do I correct this?
 
check for date difference first before calculating. If there's a date difference then add 1200 minutes to the second value (time2).

Program Error
Programmers do it one finger at a time!
 
Dickx . . . . .

Sorry to get back so late.

I forgot about [blue]midnight crossover[/blue] (sorry about that). Replace the code with the following:
Code:
[blue]= Me!Ans = DateDiff("n",Me!Time1,Me!Time2) + (Me!Time2 < Me!Time1) * (-1440)[/blue]
[purple]Cheers![/purple]

Calvin.gif
See Ya! . . . . . .
 
AceMan1

Hopefully one last question/problem. Plugging in the above code I get the following message "Production Information System can't find the field 'Ans'referred to in your expression" Correction ??

Really appreciate your help

Dickx




 
TheAceMan1 said:
DateDiff("n",Me!Time1,Me!Time2) + (Me!Time2 < Me!Time1) * (-1440)

AceMan its not like you to to do unnecessary work - what about:

DateDiff("n",Me!Time1,Me!Time2) - (Me!Time2 < Me!Time1) * 1440

[wink]

 
AceMan1

That's got it !!!!!!

Thank you very much

Dickx
 
[blue]Dickx . . . . .[/blue]
Sorry about the typo! . . . was in a hurry!

[blue]earthandfire[/blue] . . . . .
Thanks for the assist!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top