[MySQL] datetime ---> number
Hi!
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!!
Code:
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
eBookworm.us
Originally Posted by
NogDog
Code:
SELECT DATE_FORMAT(`dob`, '%Y%m%d') AS `date_ymd` FROM `table_name`;
Thanks for your reply!
What else if I want to MD5 it?
I can do the following.
Code:
SELECT MD5(dob) FROM table_name
But, how can I do MD5 with your query?
I've tested the below, but it not work.
Code:
SELECT MD5(DATE_FORMAT(`dob`, '%Y%m%d') AS `date_ymd`) FROM table_name
Thanks again!
I've got the answer.
Code:
SELECT MD5(DATE_FORMAT(`dob`, '%Y%m%d')) FROM table_name
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks