How to take the day

Asked

Viewed 41 times

0

I need to take only the "day" of the person’s birthday in SQL.

include("conexao.php");
$mes = date("m");
$consulta = $conn->query("SELECT * FROM niver WHERE niver LIKE '%".$mes."%'");
   while($linha = $consulta ->fetch(PDO::FETCH_ASSOC)) {        
     echo "
"; echo "Nome do Aniversariante: {$linha['nome']}
"; echo "{$linha['niver']}"; }

With this code I can catch the birthday kids of the current month. But now I want to show only his birthday.

  • WHERE MONTH( niver ) = mes

  • If you want to take the day, literally, use it SELECT DAY(niver) FROM ..., provided it is in DATETIME or DATE format....

  • SELECT DAY( field ) shows the day, WHERE MONTH( field ) = selects the month, and if you need year, you have the YEAR( field )

No answers

Browser other questions tagged

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