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

Military time needed from string of "2400"

Status
Not open for further replies.

ppark001

MIS
Jul 11, 2001
102
US
Hi All,

I have Crystal 8.5.

My field is a string and allows values from 0000 to 2400. This is for military time.

My problem is when I convert the string in below formula,
it errors out with times greater than 1200. Can I not start with a military time/string? It works fine for 0000 to 1200.

time({SO_95_UDF_Sales_Order_Lines.End_Time})

Thanks!

Paula
 
Try converting as:

CTime(Left({SO_95_UDF_Sales_Order_Lines.End_Time},2)+":"+Mid({SO_95_UDF_Sales_Order_Lines.End_Time},3,2))

Naith
 
or:

Time(Picture({SO_95_UDF_Sales_Order_Lines.End_Time},"xx:xx"))

Reebo
Scotland (Sunny with a Smile)
 
These formulas work for 0000 to 1200. But as soon as you enter a string that is outside the normal 1-12 time it errors out with both above formuals with "Bad Time Format String".

My field is text, is 4 in length so it's already formatted. But I can't get the hours over noon to work.

Any other ideas?

Paula
 
I tested mine with "2359", "1301" and "1815" and it worked fine.

Don't know why it wouldn't work except both myself and Naith (I think) are in the UK. Could be a configuration issue?

Post exactly which times this formula fails on.....

Reebo
Scotland (Sunny with a Smile)
 
My apologies to everyone. Hopefully my mistake will help others.

Anyway, I was using test data with several records, and one of the fields used 24:00. However, in military time, there is NO 24:00. Only 00:00 to 23:59. When Crystal errors out, it does not tell you what record it is erroring out on, only that the field has a bad time format. Which it did.

To test, I used just one record, (which is how I should of in the first place) and tested until I found my goof.

Thanks all,

Paula

 
Glad to hear it worked out.....I was going slightly mad with logic for a while there!


Reebo
Scotland (Sunny with a Smile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top