Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
APPEND FROM not Y2K ok.... know a fix?
Message
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Miscellaneous
Thread ID:
00241414
Message ID:
00241743
Views:
18
>>If I recall correctly Fox has had trouble with importing dates from SDF files dating back to FoxBASE+. While I must admit I'm a little disappointed by this news, there's a simple work around.
>
>First, remember I am in 2.6.
>
>>
>>Do the following, on the orginal table (with the actual date field), issue a call to AFIELDS(). Locate the field in question and change it from date to character. If the incoming dates are have the year in a 4 digit format with separators make the field 10 characters wide, otherwise if it's 2 digits 8. Create a cursor from the array and append the SDF file into it. Use the DBF() function to determine the actual name and location of the cursor. Then select the real table, and do an APPEND FROM (lcfile) where lcfile is the name of the cursor file. The dates in the table will be correct and the ROLLOVER clause (in the case of 2 digit years) will be respected.
>
>Once again, I am in 2.6. I did basically what you said.. but manually. Created two dbfs.... one with the date fields as C(10). I append from the text file into the DBF with character fields. Then, I use the DBF with the date fields and append from the previously created DBF. The date fields all come out empty.
>
>Unless I was doing something wrong, that is what happened.
>
Hi BOb,

The only problem with this in 2.6 should be with dates that are formatted with two digit years. 2.6 will always assume that the first 2 digits are 19. However, with 4 digit years what I'm about to type works fine. I've tested the following code in FPW 2.6a and it works fine in both cases.
m.exactstat = SET('EXACT')
SET EXACT ON
m.datefield = "MYDATE" && replace with actual date field name
m.current = ALIAS()
m.file = ""
DIMENSION a_fields[1]
= AFIELDS(a_fields)
m.pt = ASCAN(a_fields, m.datefield)
IF m.pt > 0
  * Get the row subscript
  m.pt = ASUBSCRIPT(a_fields, m.pt, 1)
  a_fields[m.pt, 2] = 'C'
  * For 4 digit years. No change for 2 digit years
  a_fields[m.pt, 3] = 10
  CREATE CURSOR Foo FROM ARRAY a_fields
  APPEND FROM (m.textfile) SDF
  m.file = DBF()
  SELECT (m.current)
  APPEND FROM (m.file)
ENDIF
IF m.exactstat = 'OFF'
  SET EXACT OFF
ENDIF
hth,
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform