List:General Discussion« Previous MessageNext Message »
From:Mike Johnson Date:November 12 2004 5:31pm
Subject:RE: What's MYSQL equivalent to Oracle's TRUNC(date_time_var)?
View as plain text  
From: sol beach [mailto:sol.beach@stripped] 

> In Oracle TRUNC(data_time_var) returns only the date portion of a
> date_time data type.
> What's the easiest way in MYSQL to accomplish the same thing?
> I tried to RTFM  (Paul DuBios' MYSQL tome; 2nd Ed.), but no clean
> solution lept out at me.
> It is a GREAT book, but it did not help me in this case.
> TIA!

Try this:

SELECT DATE_FORMAT(date_time_var, '%Y-%m-%d')

You can customize what fields you'd like in the second arg. Above will
return YYYY-MM-DD.

More here:

Also, as of 4.1.1, you can use DATE(date_time_var) to return the date


Mike Johnson             Smarter Living, Inc.
Web Developer  
mike@stripped   (617) 886-5539

What's MYSQL equivalent to Oracle's TRUNC(date_time_var)?sol beach12 Nov
  • Re: What's MYSQL equivalent to Oracle's TRUNC(date_time_var)?Bernard Clement12 Nov
RE: What's MYSQL equivalent to Oracle's TRUNC(date_time_var)?Mike Johnson12 Nov