>>>> 2013/08/21 18:03 -0400, Nick Khamis >>>>
We have the following mysql timetampe field

startdate | timestamp | NO   |     | 0000-00-00 00:00:00

When trying to insert a long value in there:

Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.getTimeInMillis();

We are presented with the following error:

com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect
datetime value: '1377119243640' for column 'stopdate' at row 1
<<<<<<<<
Ugh, where is the SQL?

In any case, although it looks as if that is MySQL s internal TIMESTAMP 
representation, one does not directly use Unix timestamps; instead, one 
converts them with the MySQL function FROM_UNIXTIME.

The same effect may be gotten with any timestamp-formatting function that 
yields a string in the form '2013/08/21 18:03:00' (it is all one whether the 
separator is hyphen, slant, colon, ...).


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql

Reply via email to