cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

what is the difference between weekday and dayofweek function in spark SQL?

mrvi2310
New Contributor II

dayofweek: https://docs.databricks.com/sql/language-manual/functions/dayofweek.html

weekday : https://docs.databricks.com/sql/language-manual/functions/weekday.html

According to the documentation , they both are synonym functions.

But when I use it I noticed that weekday starts the day count from Tuesday = 1 weekday vs dayofweek

Would this be considered a bug or do both functions mean different things?

4 REPLIES 4

Anonymous
Not applicable

Hello, @mrvi2310​! Welcome and thanks for your question. My name is Piper and I'm one of the community moderators. Let's give it a bit to see how the other members respond. We'll circle back around if we need to.

Hubert-Dudek
Esteemed Contributor III

That's correct for weekday moday=0 for dayofweek Sunday=1.​

You can also look for documentation here https://spark.apache.org/docs/latest/api/python/reference/api/pyspark.sql.functions.dayofweek.html

​https://spark.apache.org/docs/latest/api/sql/index.html

-werners-
Esteemed Contributor III

Maybe update the databricks docs, as there is indeed stated that they are synonyms.

-werners-
Esteemed Contributor III

ah yes, my bad!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group