MySQL Forums
Forum List  »  Newbie

Re: how to convert timestamp value to string in MySql
Posted by: Rick James
Date: April 26, 2009 08:30PM

In fact, almost anything string-like that you do will give you a string. Try this on your table:

 SELECT ts,
        date(ts),
        time(ts),
        left(ts, 7) AS yyyy_mm
 FROM tbl;

ts+0 will turn the timestamp into a funky number -- don't do arithmetic on that!

DATE_ADD(ts, INTERVAL 1 DAY) is the way to do date arithmetic.

Options: ReplyQuote


Subject
Written By
Posted
Re: how to convert timestamp value to string in MySql
April 26, 2009 08:30PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.