views:

207

answers:

1

I am pulling data from Twitter's API and the return date is UTC in the following form:

Sat Jan 24 22:14:29 +0000 2009

Can MySQL handle this format specifically or do I need to transform it? I am pulling the data using Python.

+3  A: 

Yes, if you are not willing to transform it in Python, MySQL can handle this with the STR_TO_DATE() function, as in the following example:

INSERT INTO
    your_table
VALUES ( 
    STR_TO_DATE('Sat Jan 24 22:14:29 +0000 2009', '%a %b %d %H:%i:%s +0000 %Y')
);

You may also want to check the full list of possible format specifiers: MySQL: DATE_FORMAT.

Daniel Vassallo
Thats great! What do you recommend the data format be in MySQL and if I wanted to, best way to do this in Python prior to MySQL import? Thanks again.
Btibert3