Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
From CSV file into MYSQL - how to transfer dates?
Old 11-17-2008, 04:34 PM From CSV file into MYSQL - how to transfer dates?
Average Talker

Posts: 19
Name: Meir Ech
Trades: 0
What should the CSV date look like
to bring it correctly into its corresponding
Mysql field, which is formatted as a 10-digit integer field?

Thank you.

Last edited by ruffy; 11-17-2008 at 04:37 PM..
ruffy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-17-2008, 04:45 PM Re: From CSV file into MYSQL - how to transfer dates?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
if your mysql field is an int(10), then don't even bother...
Drop your field, and recreate it as timestamp.

Then, you can fetch it with nearly any syntax to the db, and it shoul be able to cope with it.
Don't trust what a select shows you, a date field is totally different of an int field, and is specially designed to make life easier when dealing with dates.
Use it...
http://dev.mysql.com/doc/refman/5.0/...functions.html
Code:
mysql> select timestamp('20071215235026');
+-----------------------------+
| timestamp('20071215235026') |
+-----------------------------+
| 2007-12-15 23:50:26         | 
+-----------------------------+
1 row in set (0.00 sec)
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 11-17-2008 at 04:54 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 11-17-2008, 04:48 PM Re: From CSV file into MYSQL - how to transfer dates?
Average Talker

Posts: 19
Name: Meir Ech
Trades: 0
tripy - Having once read a superb book (by the Sitepoint people)
about dates (using PHP, Mysql and javascript), I already have a whole lot
of code resting on this 10-digit integer Mysql format.
It really proved (for me) to be the best formatting policy
with regard the aforementioned languages.
ruffy is offline
Reply With Quote
View Public Profile
 
Old 11-17-2008, 05:15 PM Re: From CSV file into MYSQL - how to transfer dates?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Ok, as you think. I understand that having an heavy code base is a major blocker to change it.
But I ,personally, as a DBA and professional SQL developer think you go the wrong way, trying to handle your date processing in php to send it to mysql.
You have an highly optimized and low level engine that is all ready to handle them for you, and I think it makes perfect sense to use it.
It can ease your computations a lot by using built-in functions.
PHP simply isn't adapted to that task when you care about performances.

And yes, I did 11 years (since PHP-FI/PHP 2.0) of PHP development as senior developer at the same time I achieved my DBA formation.
I don't say that because I don't know PHP.
I know it suffisantly to know when I should stop using it.

I simply found sad that today developers don't try to use the right tool for the right task, and try to do everything in the same place, regardless of performances and resources conservatism.

That being said, it will just let you do the php date() calls to send to the db the integer you need.
I don't see what your question is about....
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to From CSV file into MYSQL - how to transfer dates?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19957 seconds with 12 queries