what is the difference between weekday and dayofweek function in spark SQL?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Labels:
-
Databricks SQL
-
SQL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
My blog: https://databrickster.medium.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2021 03:47 AM
Maybe update the databricks docs, as there is indeed stated that they are synonyms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2021 05:17 AM
ah yes, my bad!