Importing a Date


OnBeforeEvaluateField(VAR Text : Text[260])
EVALUATE(Day,COPYSTR(Text,7,2));
EVALUATE(Month,COPYSTR(Text,5,2));
EVALUATE(Year,COPYSTR(Text,1,4));
MESSAGE('Day %1  Month %2  Year %3',Day,Month,Year);
"Any Date" := DMY2DATE(Day,Month,Year);

The client requires that data is imported into Navision on an ongoing basis. The Date format of the field being imported YYYYMMDD. I wrote the above in the Dataport trigger. The message displays the correct data. The error from Navision says that 20010714 is not a valid date. What am I doing wrong? Edited by - Matt_B on 2001 Jul 19 19:35:26

Make sure that in your dataportfield you use a text field (declare DateTxt as a Global) and NOT a date field. You get this error because I guess that “Any Date” is a date field and not a text field, This shoud do the trick (-; tarek_demiati@ureach.com

Make a Variable DateStr Code 8 Use that in your Dataport Field List IE: “No.” Name Address “Address 2” DateStr “Credit Limit” etc: Move your Code to OnAfterImportRecord() IF DateStr <> ‘’ THEN BEGIN EVALUATE(Day,COPYSTR(DateStr,7,2)); EVALUATE(Month,COPYSTR(DateStr,5,2)); EVALUATE(Year,COPYSTR(DateStr,1,4)); // Just Fill in the Date Field IE: “Posting Date” for the Record “Posting Date” := DMY2DATE(Day,Month,Year); END; // Remember to clear the variable as it will hold and use the last value if the next record has a Null Value CLEAR(DateStr); David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk Edited by - David Cox on 2001 Jul 19 21:00:08

Your problem is easier than all that… when you use the OnBeforeEvaluateField for changing the format a data is received, you just need to change the Text variable is received as parameter to the function, so your problem could be solved if changed the code on you OnBeforeEvaluateField trigger to this: OnBeforeEvaluateField(VAR Text : Text[260]) // transformation of date format from yyyymmdd to ddmmyyyy Text := COPYSTR(Text,7,2)+COPYSTR(Text,5,2)+COPYSTR(Text,1,4); Regards from Spain – Alfonso Pertierra apertierra@teleline.es Spain