Home > Mobile >  DAYNAME() function SQL
DAYNAME() function SQL

Time:10-11

I want to find out the name of the week, however when I write the DAYNAME() function in MySql it returns the following error:

Function not found: DAYNAME at [8:1]

I'm using the Google's big data console.

CodePudding user response:

Like mentionned in the documentation here : https://cloud.google.com/bigquery/docs/reference/standard-sql/date_functions

EXTRACT(part FROM date_expression)

so you want

EXTRACT(DAY FROM date_expression)

EDIT You can also use SELECT format_datetime('%A','2021-10-10') to return the DAY NAME of the string date

CodePudding user response:

In MySql you can use Date_FORMAT)

 SELECT DATE_FORMAT(NOW(), '%W');
| DATE_FORMAT(NOW(), '%W') |
| :----------------------- |
| Sunday                   |
SELECT DATE_FORMAT(NOW(), '%a');
| DATE_FORMAT(NOW(), '%a') |
| :----------------------- |
| Sun                      |

db<>fiddle here

  •  Tags:  
  • sql
  • Related