none
Convert TXT to DBF

    Question

  • how to conver Txt to DBF

    txt looks like that

    001 02082009 08:00 16:00

    and i want to use this code as date 02082009
    i can insert now in DBF
    but i need to know how to insert this data into this DBF

    thank you
    Wednesday, September 9, 2009 9:50 PM

Answers

  • -If it is your text file then first set your dateformat. ie:

    Set Date to MDY

    -Create a cursor and append from text file:

    create cursor myCursor (id c(4), myDate c(10), t1 c(5), t2 c(5))
    append from myFile.txt type delimited with blank

    -Replace myDate content usingn transform:

    replace all myDate with Transform(myDate, '@R 99/99/9999')

    -Finally alter your cursor to set datatype to date:

    alter myCursor alter column myDate d


    If you meant to only convert a single value then:

    ? ctod(Transform('02082009', '@R 99/99/9999'))
     
    • Proposed as answer by Naomi NModerator Thursday, September 10, 2009 3:32 AM
    • Marked as answer by Xingwei Hu Tuesday, September 15, 2009 11:32 AM
    Wednesday, September 9, 2009 10:27 PM

All replies

  • Parse the text to add the dashes then use CTOD()
    JLB
    Wednesday, September 9, 2009 10:07 PM
  • -If it is your text file then first set your dateformat. ie:

    Set Date to MDY

    -Create a cursor and append from text file:

    create cursor myCursor (id c(4), myDate c(10), t1 c(5), t2 c(5))
    append from myFile.txt type delimited with blank

    -Replace myDate content usingn transform:

    replace all myDate with Transform(myDate, '@R 99/99/9999')

    -Finally alter your cursor to set datatype to date:

    alter myCursor alter column myDate d


    If you meant to only convert a single value then:

    ? ctod(Transform('02082009', '@R 99/99/9999'))
     
    • Proposed as answer by Naomi NModerator Thursday, September 10, 2009 3:32 AM
    • Marked as answer by Xingwei Hu Tuesday, September 15, 2009 11:32 AM
    Wednesday, September 9, 2009 10:27 PM