>>>Hi All,
>>>
>>>Is there a better, or shall I say more elegant, way of extracting the numeric values from a date-formatted ("03/27/2014") text string than the following:
>>>
>>>lnmon=val(left(alltrim(this.text),2))
>>>lnyear=val(right(alltrim(this.text),4))
>>>lnday=val(substr(alltrim(this.text),4,2))
>>>lddate=date(lnyear,lnmon,lnday)
>>>
>>
>>I'll ask the obvious - have you tried CTOD(this.text)?
>
>
>CTOD() can do it as well but runs a risk of ambiguous date values (see the help). Using the DATE() function is safer because you need to specify the year, month and day specifically.
Chopping the string manually (as above) assumes ddmmyyyy. It doesn't know if there may be mmddyyyy dates in there, so the risk is the same.
At least, ctod() will return an empty date and won't error out on impossible values.