5

I have following insert query:

INSERT INTO `bid`.`bdate` (`id`, `bid`, `odate`) VALUES (NULL, '1', STR_TO_DATE('02-27-2011 17:58','%Y-%m-%d %H:%i:%s'))

But it is giving me errors. Can some one guide me what Iam doing wrong and how it can be rectified.

Thanks in advance

Simpanoz
  • 2,517
  • 10
  • 42
  • 64

3 Answers3

2

You have the date formats in the wrong place. Change your query to:

STR_TO_DATE('02-27-2011 17:58','%m-%d-%Y %H:%i'))
The Scrum Meister
  • 29,113
  • 8
  • 64
  • 63
2

You dont have a place holder for %s.

try this.

INSERT INTO `bid`.`bdate` (`id`, `bid`, `odate`) VALUES (NULL, '1', STR_TO_DATE('02-27-2011 17:58:00','%Y-%m-%d %H:%i:%s'))
rdp
  • 2,022
  • 4
  • 31
  • 53
2

Try this,

$datetime = strtotime($row->createdate);
$mysqldate = date("m/d/y g:i A", $datetime);
Yoko Zunna
  • 1,774
  • 13
  • 21