how to truncate a MySQL date

how to truncate a MySQL date

am 08.03.2006 04:15:59 von laredotornado

Hi,

I have a MySQL column that's of a DATETIME type. What MySQL function
can I apply to it in a SELECT statement to make the time midnight? FOr
example, if a value of the column was

2006-03-07 21:00:00

I'd like to apply a MySQL function and make the value

2006-03-07 00:00:00

THanks for your help, - Dave

Re: how to truncate a MySQL date

am 11.03.2006 19:41:43 von nc

laredotornado@zipmail.com wrote:
>
> I have a MySQL column that's of a DATETIME type. What MySQL function
> can I apply to it in a SELECT statement to make the time midnight? FOr
> example, if a value of the column was
>
> 2006-03-07 21:00:00
>
> I'd like to apply a MySQL function and make the value
>
> 2006-03-07 00:00:00

This should work:

UPDATE mytable
SET myDTcolumn = DATE_FORMAT(myDTcolumn, '%Y-%m-%d 00:00:00');

Cheers,
NC