datetime - Date insert into mysql table -
my sql insert date(%d-%m-%y)
has 0 effect on field no data added. neither did inserting 02-dec-2010
. have change table field type or default date inserted in 02-dec-2010 format?
field: creationdate type: timestamp default: current_timestamp (showing 0000-00-00 00:00:00)
you don't pre-format dates. insert timestamp formatted yyyy-mm-dd hh:ii:ss , when need format date (select statement), use date_format function.
if have timestamp 02-dec-2010, can use str_to_date function convert real timestamp.
mysql> select date_format(current_date, '%d-%b-%y'); +--------------------------------+ | date_format(now(), '%d-%b-%y') | +--------------------------------+ | 02-dec-2010 | +--------------------------------+ mysql> select str_to_date('02-dec-2010', '%d-%b-%y'); +----------------------------------------+ | str_to_date('02-dec-2010', '%d-%b-%y') | +----------------------------------------+ | 2010-12-02 | +----------------------------------------+
Comments
Post a Comment