Good day) Advice please - is it permissible to use this syntax -

insert into EXAM_MARKS ( EXAM_DATE)
values (str_to_date('26-05-2000', '%d,%m,%y'));

This line does not work. I can not understand on what went wrong.
Thank you for your answers)

Good day) Advice please - is it permissible to use this syntax -

insert into EXAM_MARKS ( EXAM_DATE)
values (str_to_date('26-05-2000', '%d,%m,%y'));

This line does not work. I can not understand on what went wrong.
Thank you for your answers)

I am using this date function in php forms:

example:

$date=date("Y-m-d", strtotime(25-05-2006));

commented: +++ +1

Thank you, Boskor. But I still haven't figured out the problem.

this command will work in the following format -

insert into EXAM_MARKS ( EXAM_DATE)
      values (str_to_date('26[B],[/B]05[B],[/B]2000', '%d,%m,%[B]Y[/B]'));

but I do not understand why the letter "y" in the format is capital)

When you use the str_to_date function you have to pass a date in the first parameter then the second parameter must match the format of your date. In the first example:

insert into EXAM_MARKS ( EXAM_DATE)
      values (str_to_date('26-05-2000', '%d,%m,%Y'));

You have dashes in the date parameter but commas in the second parameter and they have to match. So when you enter the second query:

insert into EXAM_MARKS ( EXAM_DATE)
      values (str_to_date('26,05,2000', '%d,%m,%Y'));

You have commas in both and the date format matches in both parameters.

For the other question the letter must be Y capital because that is the year with 4 digits (2000) and that's the format of your string. If it where y lower case, then it would be looking for a year of 2 digits (00 for two thousand) which is not the case for your date because your year is in the 4 digits format.

commented: ++++++ +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.