โ12-10-2021 03:20 PM
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
Would this be considered a bug or do both functions mean different things?
โ12-10-2021 04:40 PM
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.
โ12-11-2021 02:37 AM
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
โ12-13-2021 03:45 AM
Hi @mrvi2310โ , As @Hubert Dudekโ has rightly mentioned, here are the screenshots:-
References:- https://spark.apache.org/docs/latest/api/sql/
โ12-13-2021 03:47 AM
Maybe update the databricks docs, as there is indeed stated that they are synonyms.
โ12-13-2021 05:03 AM
Hi @Werner Stinckensโ , It's truly appreciated that you flagged the information here. However, as I've checked the databricks docs now, it's mentioned the same as I and @Hubert Dudekโhave stated.
It states that these functions are synonyms of the function extract(DAYOFWEEK FROM expr) and are not synonyms to each other. I've attached the screenshots below.
References:- https://docs.databricks.com/sql/language-manual/functions/dayofweek.html
https://docs.databricks.com/sql/language-manual/functions/weekday.html
UPDATE:-
An update is required in the function WEEKDAY where it's stated that it returns an INTEGER where 1 = Sunday and 7 = Saturday.
It should have been that it returns an integer where 0 = Monday, 6 = Sunday).
โ12-13-2021 05:17 AM
ah yes, my bad!
โ12-13-2021 05:31 AM
No worries!
Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections.
Click here to register and join today!
Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.