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!

Convert a string to a date

Status
Not open for further replies.
Aug 15, 2008
18
GB
Hi,

I'm trying to convert a string to a date. The string is in the format of "200809092. I'm using the formula of

Function (stringvar apex_date);
cdate(apex_date[7 to 8] &"/" &
apex_date [5 to 6]&"/" &
apex_date [1 to 4])

There are no conditions for the user when entering the string. When the reports comes acorss an invalid string eg "20080932", it fails. How can I add a condition to check the string prior to converting to a date?

Thanks, in advance.

JC
 
Hi,
If there are no constraints on what the user may enter, then checking for all possible variants is not feasable.

The Date(string) function in CR can recognize most date string formats, but there must be some way you can constrain the user input.

If not, then treat the inputted string as an array and based on what each position holds, devise a formula to reformat the way it is needed..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top