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: Mon Dec 1 12:34:03 EST 2008

Total time taken to generate the page: 0.01262 seconds
.:: Contact :: Home :: MySQL Support by Percona.com ::.

Powered by: FUDforum 2.7.5.
Copyright ©2001-2006 FUD Forum Bulletin Board Software

MySQL Performance | Forum authority Badge