Reputation: 1562
I want to display the day on which a user born. I have date-of-birth column in my table in date Format. So please let me know the solution for the problem. I tried myself, then I tried to get it over internet, but got several results for other database like oracle and sqlserver, so please let me know how to get it .
Thanks in advance..!
Upvotes: 2
Views: 1318
Reputation: 29809
[edit]
SELECT DAYNAME('2012-12-27');
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_dayname
Upvotes: 6
Reputation: 601
if you name of day then use :-
SELECT DAYNAME('2007-02-03');
or if want day of week then use
SELECT DAYOFWEEK('2012-12-27);
for more detail visit:-
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_dayname
Upvotes: 1
Reputation: 24144
Use EXTRACT() function
select
EXTRACT(YEAR FROM BirthDate),
EXTRACT(MONTH FROM BirthDate),
EXTRACT(DAY FROM BirthDate)
from t
Upvotes: 1
Reputation: 75699
You can use DATE_FORMAT with %w or %W:
DATE_FORMAT('2012-12-27', '%w');
Upvotes: 1