0

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)

3
Contributors
4
Replies
12
Views
6 Years
Discussion Span
Last Post by asaenz
1

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));

Votes + Comments
0

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)

Edited by vedro-compota: n/a

1

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.

Votes + Comments
++++++
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.