Text yyyymmdd to Date? How?

I am creating a dataport and the .csv file date format is YYYYMMDD. How can I convert that to a Navision Date field? I have tried CopyStr into three parts and tried concating them back into MMDDYYYY but I get a type error.

Have you tried: evaluate (datovar,copystr(strvar,7,2)+copystr(strvar,5,2)+copystr(strvar,1,4));?

Hi SWebb You should use DMY2DATE D := DMY2DATE(Day, Month, Year); Regards Gudmundur

Gudmundur, I was about to suggest the same, but there’s a little difference: DMY2DATE needs parameters of type integer, while SWebb has the date components as strings! [;)]

Sweb, try this: Use COPYSTR to create 3 parts of the TXT String. Then use EVALUATE to evaluate the strings into INTEGER. Then use D := DMY2DATE(Day, Month, Year) to create your date. I am sure this should solve your problem…

I have the same problem months ago and I use evaluate like John Mikkelsen says and it works. evaluate (datovar,copystr(strvar,7,2)+copystr(strvar,5,2)+copystr(strvar,1,4)); No more code is needed. Best regards.

Hi, 1. Seprate it into three parts. 2. convert all the three text into integer by using EVALUATE function. 3. use DMY2DATE function.

Right, Rajeshj. As I wrote a few days ago…:slight_smile: Brgds Roland