Is it possible to use the DATENAME() function with the mysql datetime format?

Asked

Viewed 20 times

0

How are you doing? am here with a question I am creating a website in HTML and PHP and wanted to show some data from mysql database, I have a field that is autoincrement that is datetime and with this field wanted to show the date itself and then also show the day of the week type (MONDAY, TUESDAY...) only that I’ve done 1001 searches and I’m doing exactly as they say and it doesn’t work for me... I wonder if you could lend a hand?

code:

$sql = "SELECT DATENAME(weekday, data), temperature, humidity FROM sensor WHERE `data` < (NOW() - INTERVAL 7 DAY) ORDER BY data DESC LIMIT 1";
  • Are you sure the function is DATENAME? Would not be DAYNAME(data)? https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html

  • Thanks for the help friend! Actually it was just that... others said to add weekday but this perfect!

No answers

Browser other questions tagged

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