I am using this date conversion to convert AS400 dates to a calendar date:
Function (numberVar ConvertDate)
// @ConvertDate
// substitute {the AS400 date field} for the number field that is to be converted to a date
local numbervar AS400date := ConvertDate;
// converts the number to a text field
// this is so that the field can be parsed out into year, month, day
local stringvar AS400string := totext(AS400date, 0, "");
local numbervar fieldlength := length(AS400string);
// determines the year
local numbervar ASyear := 1900 + tonumber((AS400string)[1 to fieldlength - 4]);
// determines the day
local numbervar ASday := tonumber(right(AS400string, 2));
// determines the month
local numbervar ASmonth := tonumber(AS400string[(fieldlength - 3) to (fieldlength - 2)]);
// truedate is the final result in the formula that displays
// the date into a true date type in Crystal Reports
local datevar truedate := date(ASyear, ASmonth, ASday);
truedate;
My problem is the field I am trying to convert has some null values for this date and it returns an error that the subscript must be between 1 and the length of the script. Any ideas how to make get past the null fields?
Thanks,
Function (numberVar ConvertDate)
// @ConvertDate
// substitute {the AS400 date field} for the number field that is to be converted to a date
local numbervar AS400date := ConvertDate;
// converts the number to a text field
// this is so that the field can be parsed out into year, month, day
local stringvar AS400string := totext(AS400date, 0, "");
local numbervar fieldlength := length(AS400string);
// determines the year
local numbervar ASyear := 1900 + tonumber((AS400string)[1 to fieldlength - 4]);
// determines the day
local numbervar ASday := tonumber(right(AS400string, 2));
// determines the month
local numbervar ASmonth := tonumber(AS400string[(fieldlength - 3) to (fieldlength - 2)]);
// truedate is the final result in the formula that displays
// the date into a true date type in Crystal Reports
local datevar truedate := date(ASyear, ASmonth, ASday);
truedate;
My problem is the field I am trying to convert has some null values for this date and it returns an error that the subscript must be between 1 and the length of the script. Any ideas how to make get past the null fields?
Thanks,