Chella
Chella

Reputation: 1562

how to display the day on which a user born in mysql?

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

Answers (5)

RandomSeed
RandomSeed

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

Nipun Jain
Nipun Jain

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

Saharsh Shah
Saharsh Shah

Reputation: 29071

Try this:

SELECT DAYNAME('2012-12-27');

Output

Thursday

Upvotes: 1

valex
valex

Reputation: 24144

Use EXTRACT() function

select  
     EXTRACT(YEAR FROM BirthDate), 
     EXTRACT(MONTH FROM BirthDate), 
     EXTRACT(DAY FROM BirthDate) 
from t

Upvotes: 1

Sjoerd
Sjoerd

Reputation: 75699

You can use DATE_FORMAT with %w or %W:

DATE_FORMAT('2012-12-27', '%w');
  • %W = Weekday name (Sunday..Saturday)
  • %w = Day of the week (0=Sunday..6=Saturday)

Upvotes: 1

Related Questions