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,729
  • 10
  • 43
  • 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,681
  • 8
  • 66
  • 64
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,072
  • 4
  • 31
  • 55
2

Try this,

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