ChadSmiley Blog Things about family, life, coding, and more

11May/060

SnT Thursday – Military Time

Ever wanted to categories information based on date\time.The sorting was not whate I expected becase 10:44 AM is after 09:08 AM. Military time was the first thing that came to mind and I found just what I was looking for at Lotus Notes FAQ - How do you convert a time field to display as military time? from Key Yee. I did add the date to the string, the only chnage is contacting the hour, minute and seconds into an array and then imploding it using a colon, which is quicker than h + ":" + m +":" + s.

REM {From Jason Collier (jcollier@sd.synetics.com)}; 
DateTime := @Created; 
time := @Time(dateTime); 
t:= @Text(@Time(time)); 
t2:=@Left(@Text(@ReplaceSubstring(@Text(@Time(time)); ":" ;"")); 6); 
h:=@Left(t2;2); 
s:=@Right(t2;2); 
m:=@Middle(t2;2;2); 
AM:=@ReplaceSubstring(@Left(t2;2) ; "12" ;"00"); 
 PM:=@ReplaceSubstring(@Left(t2;2) ; "12" ;"12"); 
 PM2:=@Text(@TextToNumber(h)+12); 
 timecheck:= @If(@Contains(t;"AM"); AM ; @If(@Contains(t;"PM") & @Contains(@Left(t2;2);"12") ; PM ; PM2)); 
 MilTime := timecheck : m : s ; 
   @Text( @Date( DateTime ) ) + "\\" + @Implode( MilTime ; ":" )
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.