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

Military Time conversion

Status
Not open for further replies.

SharonBrown

Technical User
Mar 2, 2001
3
US
Below is a formula we use to convert military to civilian time. It works except for one problem, any time between 00:00 and 00:14 does not show 12:00 am or 12:14 am, it give
00:14. I need it to show Civilian time.

Any suggestions?

WhilePrintingRecords ();
StringVar szTime;
if({CASE_INFORMATION.case_toi} = " " or IsNull ({CASE_INFORMATION.case_toi})) or Left(ToText({CASE_INFORMATION.case_toi}) ,2) = "0"
then
szTime:=" "
else
If(ToNumber ({CASE_INFORMATION.case_toi})) >= 1200
then If(ToNumber ({CASE_INFORMATION.case_toi}) >= 1259 and ToNumber ({CASE_INFORMATION.case_toi}) < 2200)
then szTime:=Picture(ToText ((ToNumber ({CASE_INFORMATION.case_toi}) -1200),0,&quot;&quot;,&quot;&quot;) ,&quot;X:XX pm&quot;)
else If(ToNumber ({CASE_INFORMATION.case_toi}) >= 2200)
then szTime:=Picture(ToText ((ToNumber ({CASE_INFORMATION.case_toi}) -1200),0,&quot;&quot;,&quot;&quot;) ,&quot;XX:XX pm&quot;)
else szTime:= Picture({CASE_INFORMATION.case_toi}, &quot;XX:XX pm&quot;)
else szTime:= Picture({CASE_INFORMATION.case_toi}, &quot;XX:XX am&quot;);


 
This will convert a military time string to civilian time.



totext(timevalue({YourMilitaryTimeField}), 'hh:mm tt')
 
Note that the TimeValue function is only in V8.x

You will probably want keep your first IF to check for blanks,nulls, etc. which may cause the timevalue formula to choke. Ken Hamady, On-site/Phone Crystal Reports Training/Consulting
Quick Reference Guide to using Crystal in VB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top