Re: inserting date from text file
| From: | CPT John W. Holmes | Date: | Wed, 15 Oct 2003 21:10:33 +0000 |
| Subject: | Re: inserting date from text file | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-31028@lists.php.net to get a copy of this message | ||
From: "Aleks @ USA.net" <Aleks.k@usa.net>
> I have a large text file that I am inserting into a mysql db and seem to
> have a problem with
> the date format. The data is currently in the mm/dd/yyyy format.
MySQL expects a YYYYMMDD or YYYY-MM-DD format (the delimiter for the string
version can be any character, actually)
> I am using phpMyAdmin with the above command. I have over 1000 lines of
data
> to add and
> changing all the dates would be a royal pain. Is the note a way to set the
> format in the
> column description to allow for the current data format to remain as is
and
> have the
> db insert the date in the correct mySQL format??
There's no way to set a format. You could insert them into a VARCHAR column,
then use an UPDATE query to pull the string apart and format it into
YYYYMMDD and update another DATE column, though.
Or have PHP run pre-process your text file and change the dates for you
(since this is a PHP list. :))
---John Holmes...