[MySQL] datetime ---> number
I've a table with a coloum "dob", the type of it is datetime.
I could like to convert the datetime to number. For example, 1980-12-28 00:00, I want it convert to 19801228.
How can I do it in MySQL (through phpMyAdmin)?
[see also this thread]
Thanks in advance!!
SELECT DATE_FORMAT(`dob`, '%Y%m%d') AS `date_ymd` FROM `table_name`;
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Thanks for your reply!
Originally Posted by NogDog
What else if I want to MD5 it?
I can do the following.
But, how can I do MD5 with your query?
SELECT MD5(dob) FROM table_name
I've tested the below, but it not work.
SELECT MD5(DATE_FORMAT(`dob`, '%Y%m%d') AS `date_ymd`) FROM table_name
I've got the answer.
SELECT MD5(DATE_FORMAT(`dob`, '%Y%m%d')) FROM table_name
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)