Getting day name in metabase

Hey guys!

I’ve been trying to group by day name using SQL queries in metabase but unfortunately I couldn’t.
There are multiple ways to do it in SQL server, like using DAYNAME, DATENAME functions, but those don’t work in metabase. Any idea how to use it? or if there’s a replacement?

Hi @khalid4294
Why are DAYNAME/DATENAME not working in Metabase, when you create a Native/SQL question?
Can you post the query?

This works for me:

select  orderid, OrderDate, datename(dw,OrderDate) as dayofweek FROM ORDERS

I get this error (Function not found: datename; Did you mean datetime? at [2:14])
on this simple query: select oid, datename(dw,createdAt) as days FROM Orders

doesn’t work for me, “function not found”

I’m running MS SQL Server 2017. It wasn’t available until SQL 2016. What version are you running?

yeah, turned out I’m using ANSI SQL 2011. I found another way to solve this.

select id, format_timestamp('%A', createdAt) as days FROM Orders

thanks everyone!

Hey! Is there a function like DAYNAME in Metabase? I have a date and I need to find what is the day of the week, please.

@Laura.dropp No, you will have to use SQL for functions like that. You can group by a timestamp with "Day of Week" if that is what you are looking for.

I'm using SQL, I have a column with a Data (timestamp), and I want to add another column with the name of the day of the week (sun, mon..). Like the function DAYNAME. Is it possible, please?

@Laura.dropp The functions available in the native SQL editor depends on the database you are using, not a limitation of Metabase. Have a look in the documentation for your database.