View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robert Crandal[_3_] Robert Crandal[_3_] is offline
external usenet poster
 
Posts: 161
Default Convert string to military time string

I would like to hear everyone's techniques for converting
a string into military time format ONLY if the string resembles
a standard time format.

For example,

"12:00am" -- "0000"
"8:45 pm" -- "1945"
"1:22 PM" -- "1322"
"3 : 36 p m -- "1546"
"2:00" -- "0200" [special case]
"hello" -- "0000" [special case]

In the special cases where a user forgets to
type "am", "AM", "pm", or "PM", I will want to
covert as shown above (morning military time).

If the string does not resemble a standard time
format, then we can just convert that to "0000" hours.