0

I want to insert into table some particular values. However, I can not add date to my table. Other values can be added easily. I used this query

INSERT INTO `student` (`bdate`) VALUES ('30.05.1992');

I need to add in this format. I tried to use DATE_FORMAT('30.05.1992','%d.%m.%y') it also didn't help.

Soulmaster
  • 101
  • 1
  • 9

3 Answers3

1
INSERT INTO `student` (`bdate`) VALUES (STR_TO_DATE('30.05.1992', '%d.%m.%Y'));
mmuzahid
  • 2,252
  • 23
  • 42
0

If your field type is date then you can insert data in yyyy-mm-dd format only, even at the time of fetching data you can convert it into your own format.

If you want to insert date in your own format then you can use varchar data type, even at the time of fetching data it will not be optimized and you can get slowness.

Zafar Malik
  • 6,734
  • 2
  • 19
  • 30
0

It should be

INSERT INTO `student` (`bdate`) VALUES (STR_TO_DATE('30.05.1992', '%d.%m.%Y'));

as year is 4 digit such that 1992,so it should be %Y

aroy
  • 452
  • 2
  • 10