View Single Post

   
  #6 (permalink)  
Old 03-01-2008, 03:49 PM
Rik Wasmus
 
Posts: n/a
Default Re: Why TimeStamp was truncated?

On Thu, 28 Feb 2008 17:12:11 +0100, Captain Paralytic
<paul_lautman@yahoo.com> wrote:

> On 28 Feb, 16:05, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>> On Thu, 28 Feb 2008 16:58:50 +0100, howa <howac...@gmail.com> wrote:
>> > On 2月28日, 下午6時48分, "Rik Wasmus" <luiheidsgoe...@hotmail.com>

>> wrote:
>> >> On Thu, 28 Feb 2008 11:43:18 +0100, howa <howac...@gmail.com> wrote:
>> >> > CREATE TABLE `table1` (
>> >> > `ts` TIMESTAMP NOT NULL
>> >> > ) ENGINE = innodb;

>>
>> >> > INSERT INTO `table1` (`ts`) VALUES ('1202832067');
>> >> > INSERT INTO `table1` (`ts`) VALUES ( UNIX_TIMESTAMP('1202832067')

>> );
>>
>> >> > The table result is storing "0000-00-00 00:00:00" for both queries,
>> >> > any idea?

>>
>> >> Because MySQL doesn't automatically convert an integer to a datetime
>> >> string.
>> >> INSERT INTO `table1` (`ts`) VALUES ( FROM_UNIXTIME('1202832067') );

>>
>> > Hello, If I have millions of row of UNIX timestamps to insert, I don't
>> > want to invoke the method everytime, are there any faster method?

>>
>> Add an int column ('timestampcolumn') to the table, load it in there,
>> and
>> then run:
>> UPDATE table SET datetimecolumn = FROM_UNIXTIME(timestampcolumn);

>
> But this still invokes the method once per row.


It would, I'm just assuming (perhaps in error) that the OP has some import
to do, from something like a dump or csv file, where it's pretty hard to
get it to run for every row. If not, this method indeed surely only adds
problems rather then solving them.
--
Rik Wasmus
Reply With Quote