Home » Performance » MySQL » STR_TO_DATE does not function when using only year and month?
STR_TO_DATE does not function when using only year and month? [message #3170] Tue, 10 June 2008 10:50
festerwim  is currently offline festerwim
Messages: 3
Registered: May 2008
Location: Belgium
Junior Member
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

Read Message
Previous Topic:Memory tables max size
Next Topic:Joining rows based on their timestamp
Goto Forum:

  


Current Time: Thu Jul 9 22:33:49 EDT 2009

Total time taken to generate the page: 0.02079 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7.
Copyright ©2001-2007 FUD Forum Bulletin Board Software

MySQL is a trademark of Sun Microsystems.
InnoDB is a trademark of Oracle Corp.

Percona Performance Forums are a service of Percona, Inc.
Not affiliated with Sun Microsystems or Oracle Corp.