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

String Time to Time

Status
Not open for further replies.

deemat

MIS
Jan 20, 2006
24
0
0
US
Hello,
I'm trying to convert a string time to an actual time. I've searched some of the formulas provided here but still can't get what I need.

I am using -
time(val(left({time.final_data_entry_time},2)),val(mid({time.final_data_entry_time},3,2)),
val(right({time.final_data_entry_time},5)))

String time is 08:56 AM
The formula gives me 8:00:56AM - I'm not sure how the formula is working so I don't know what else to do from here. I have tried different variations but still can't get what I need.

After I do get the time working correctly, I will need to combine with a date field and the create a parameter off this new date time field. Is this even possible?

Any help given would be greatly appreciated.
 
Your formula has a couple of problems. The "minutes" component is starting at the colon which is the 3rd character in the string rather than the 4th and therefore returning zero when converted to a number. Also, the "seconds" component is returning the last 5 characters of the string ("56 AM"), so the time becomes 08:00:56

Assuming the string is consistently in the format of the example you provided, you could simply use a formula:

Code:
Time({time.final_data_entry_time})

Hope this helps.

As for the second part of your qestion I am not sure I understand. If you are saying you want to create a date/time parameter to return matching records based on the result of this formula, the answer is yes, but it will be very inneficient as every record in the table would need to be returned to the report so that Crystal could use the formula to convert the data, and then exclude those records that do not match the parameter. For the purpose of record selection, I would use string parameters if possible.

If you can give us some more insight into what you are trying to achieve we should be able to give you a the most efficient approach.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top