phone: (540)338-0194

´╗┐ ReCrystalize

Character Date to True Date:

These formulas convert Dates stored as character values into true date values.  If your formula already has separator characters in it (slashes, dashes, etc) you can use a very simple formula like this:

        If IsDate ({Table.TextDate}) then DateValue({Table.TextDate})

If your date field string doesn't have separators, then the formula below can add them so that the string can be recognized as a date value. 

        Local stringvar z := {Table.TextDate};
        z := Picture (z, 'xxxx-xx-xx');
        If IsDate (z)
        then DateValue(z)

If your date string has the year, month, day in a different order then you might need to tweek the Picture() function so that the dashes are in the right place to separate the year, month and day.  The order isn't critical because the functions can recognize dates in many different formats.  If you want a better understanding of how this formula works you can read this article from my blog.