Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date problem with APPEND FROM csv file
Message
From
07/09/2016 19:17:18
 
 
To
07/09/2016 18:49:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01640585
Message ID:
01640594
Views:
71
>>>I'm developing have a little utility that imports data from .CSV files. I have problems with some dates. I have set:
>>>
>>>SET DATE BRITISH
>>>SET CENTURY ON
>>>
>>>Dates come in british form (dd/mm/yyyy), they are NOT enclosed in quotation marks, they arrive to date type fields. After the APPEND FROM these dates suffer changes:
>>>
>>>CSV => VFP Cursor
>>>16/05/1968 => 16/05/2019
>>>19/06/2011 => 19/06/2020
>>>02/04/1973 => 04/02/1973
>>>11/08/2015 => 08/11/2015
>>>04/05/1938 => 05/04/1938
>>>26/07/2016 => 26/07/2020
>>>22/05/2004 => 22/05/2020
>>>24/03/2015 => 24/03/2020
>>>13/09/1980 => 13/09/2019
>>>16/05/1963 => 16/05/2019
>>>
>>>I tried changing to SET DATE AMERICAN and it becomes worst, the dates which previously are converted to end in 2020 appears blank.
>>>
>>>Does anyone have an idea?
>>>
>>>TIA
>>
>>It looks like you are somehow only reading the first 8 characters in each date and then trying to convert that to a date, but that doesn't explain the switching of days and months.
>>
>>if you take the first date, for example and cut off the last 2 characters you get this: 16/05/19 which when converted to a proper date will add in the century of 20 to give you this: 16/05/2019
>>
>>Can you post your code and a few records from the CSV?
>
>I create a and fill the cursor with the following:
>
>CREATE CURSOR MyCursor (perfil C(1), act_med C(7), anno N(4), autog C(15), caso C(2), cas_ref C(3), codcen C(4), cod_egre C(1), complica N(2);
> , diag C(7), diag2 C(7), diag3 C(7), diagegre2 C(7), diagegre3 C(7), dias N(3), dias_esta N(5), edad N(3), fecha D, fec_egre D;
> , fec_nac D, gdx C(3), gere C(3), historia C(7), horae C(8), horai C(8), id C(6), mes N(2), meses N(3), nive C(2), nombre C(40);
> , pac_e C(1), pac_s C(1), prioridad C(1), refere C(1), referido C(3), semana N(2), servi C(3), servirgh C(3), sexo C(1), tipat C(1);
> , tipo_ase C(2), topico C(20), ubigeo C(6), svei N(1), idmes C(2), sele N(1), epidem N(1))
>
>APPEND FROM "MyCSV.csv" TYPE CSV && CSV is attached.
>GO TOP
>BROWSE NOMODIFY && To see data.
>
>Following is 10 lines of the CSV file, I tried to atach it as a ZIP file but it does not allow. You can copy ans paste to an empty CSV file:
>
>perfil,act_med,anno,autog,caso,cas_ref,codcen,cod_egre,complica,diag,diag2,diag3,diagegre2,diagegre3,dias,dias_esta,edad,fecha,fec_egre,fec_nac,gdx,gere,historia,horae,horai,id,mes,meses,nive,nombre,pac_e,pac_s,prioridad,refere,referido,semana,servi,servirgh,sexo,tipat,tipo_ase,topico,ubigeo,svei,idmes,sele,epidem
>C,5007,2016,1508110VLTRL006,D, ,129, ,0,J02.9,,, , ,0,0,0,30/07/2016,01/01/2000,11/08/2015, ,26,6292, , , ,9,0, ,VALLE TORRES LAIA,C,C, , , ,30, ,AB1,F, ,1, ,0,1,GG,0,1
>C,5006,2016,1106191MAAZJ001,D, ,129, ,0,L91.0,,, , ,0,0,5,30/07/2016,01/01/2000,19/06/2011, ,26,5246, , , ,9,0, ,MAMANI APAZA JAIR,C,C, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1
>C,5004,2016,7304021QSTTF007,D, ,129, ,0,S05.1,,, , ,0,0,43,30/07/2016,01/01/2000,02/04/1973, ,26,5462, , , ,9,0, ,QUISPE TTITO FRANCISCO,C,C, , , ,30, ,AB1,M, ,75, ,0,1,GG,0,1
>C,5002,2016,3805041SAMAP008,D, ,129, ,0,J15.2,,, , ,0,0,78,30/07/2016,01/01/2000,04/05/1938, ,26,553, , , ,9,0, ,SALAS MAMANI PAULINO,C,C, , , ,30, ,AB1,M, ,7, ,0,1,GG,0,1
>C,4999,2016,7704121CLFNF006,D, ,129, ,0,J32.1,,, , ,0,0,39,30/07/2016,01/01/2000,12/04/1977, ,26,6554, , , ,9,0, ,CUELLAR FERNANDEZ FABIAN,C,C, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1
>C,4998,2016,5901070PTPOJ008,D, ,129, ,0,G44.2,,, , ,0,0,57,30/07/2016,01/01/2000,07/01/1959, ,26,598, , , ,9,0, ,PASTOR PALOMINO JULIA,C,C, , , ,30, ,AB1,F, ,7, ,0,1,GG,0,1
>C,4997,2016,0405220FSPAN001,D, ,129, ,0,J02.9,,, , ,0,0,12,30/07/2016,01/01/2000,22/05/2004, ,26,5291, , , ,9,0, ,FRISANCHO PIÑA NADIUSKA,N,N, , , ,30, ,AB1,F, ,1, ,0,1,GG,0,1
>C,4996,2016,1503241FSPAA000,D, ,129, ,0,J00.X ,,, , ,0,0,1,30/07/2016,01/01/2000,24/03/2015, ,26,6344, , , ,9,0, ,FRISANCHO PIÑA AARON,N,N, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1
>C,4993,2016,6805160RAQSJ002,D, ,129, ,0,Z71.2,,, , ,0,0,48,30/07/2016,01/01/2000,16/05/1968, ,26,6501, , , ,9,0, ,ROMAN QUISPE DE PORTILLO JUANA,C,C, , , ,30, ,AB1,F, ,7, ,0,1,GG,0,1
>C,4992,2016,1012151AIPHL008,D, ,129, ,0,J02.9,,, , ,0,0,5,30/07/2016,01/01/2000,15/12/2010, ,26,6379, , , ,9,0, ,DEL AGUILA PASHANASTE LLEN,C,C, , , ,30, ,AB1,M, ,1, ,0,1,GG,0,1

Which column if the one giving the problem?

What is your setting of set century?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform