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?

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
Databricks MVP

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


My blog: https://databrickster.medium.com/

-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!