import csv file

Discussion in 'PHP' started by kichus, Dec 8, 2005.

  1. #1
    i have a csv file which i need import to mysql database.

    I am able to do all the fileds except the date.how can I convert the date format in csv to mysql date format, before inserting to database
     
    kichus, Dec 8, 2005 IP
  2. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could import it and then write a script that went through each record and altered the date from its current format to a mysql format.

    I think you may need to have 2 date columns in the database - one for the format you upload the date in and then another to put the sql format after you convert it.
     
    dave487, Dec 8, 2005 IP
  3. philej

    philej Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What format is the date you're importing?
     
    philej, Dec 8, 2005 IP
  4. kichus

    kichus Peon

    Messages:
    188
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    the date format in csv is mm/dd/yyyy i had to convert it into yyyy/mm/dd before inserting to mysql

    I got it working now

    From the array I stored the date value into a variable... took substring... and checked each value in condion

    It was lengthy process but got it right... thanks all
     
    kichus, Dec 8, 2005 IP