Announcement

Announcement Module
Collapse
No announcement yet.

STR_TO_DATE does not function when using only year and month?

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • STR_TO_DATE does not function when using only year and month?

    Either STR_TO_DATE does not work properly or I'm doing something wrong. Consider this statement:

    SELECT DATE_FORMAT( NOW(), '%Y%m');

    This will output '200806' since we are currently June in the year 2008.
    Then do this:

    SELECT STR_TO_DATE(DATE_FORMAT( NOW(), '%Y%m'), '%Y%m');

    This outputs:
    31-mei-2008 0:00:00

    I would expect it to have printed out:
    1-june-2008 0:00:00

    Anybody has an idea why this might happen?

    I need this because I want to group by month and want to have a column 'CalculatedDate' which contains a real date with the first of each month in it.

    regards,

    Wim
Working...
X