SQL query for date return

Asked

Viewed 137 times

-4

I can’t seem to solve this comic book exercise.

Ask to use the sql date function. We have the date in day/month/year format, we have to extract the month. We have the seller table containing codvend, nomevend and dt_nasc.

Question: List all sellers who have birthday between January and June returning the name of the month.

Please, if anyone can help me, I’d be very grateful. Thank you.

  • 5

    Hello Marilia, and welcome from [pt.so]. The dynamics of the community is a little different, I recommend that you take a tour by [tour], [help] and mainly [Ask]. Post more information, your attempts and show the effort you made before bringing the question.

  • 1

    What is the format of your tables?

  • 1

    http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html Use date and time functions for this.

  • 2

    You’ll have to do more research.

1 answer

2

List all sellers who have birthday between January and June returning the name of the month. (Edit the table and field name according to your current table)

SELECT id_vendedor, nome_vendedor, MONTHNAME(dt_nascimento) as MesAniversario 
FROM vendedor WHERE MONTH(dt_nascimento) BETWEEN 1 AND 6;

Reference: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

Browser other questions tagged

You are not signed in. Login or sign up in order to post.