YEARWEEK Function and Modes
Hello all -
I am looking for some help with the YEARWEEK() function. I see that the function syntax is:
YEARWEEK(`dateCol`, mode)
where 'mode' defines the starting day of the week with '11' meaning Sun-Sat and '22' being Mon-Sun. I found this in the Beast Mode Functions Reference Guide but it doesn't expand whether other day ranges can be used and what their codes would be.
I would like to use Sat-Fri as my week but I can't find what mode code that would apply to, if at all?
Thanks for any help!
Best Answer
-
Sadly this seems to be one of the functions that is not homologous to its MySQL counterpart, so unless someone has tried it, I don't think we'll have much extra documentation (You can always test and share your findings here, from my initial test any other number results in the same behavior as 11).
You could hack your way around this by using a DATE_ADD or DATE_SUB to move your actual date a couple of days so that the displaced calendar would align with weeks Sat-Fri, but this becomes tricky when you approach the beginning or end of the year.
YEARWEEK(DATE_ADD(`dt`,INTERVAL 1 DAY),11)
Will give you weeks starting on Saturday, but as explained if might work weirdly towards the start or end of a year. In here you can see that it considers 12/31/2022 as Week 202301.
1
Answers
-
Sadly this seems to be one of the functions that is not homologous to its MySQL counterpart, so unless someone has tried it, I don't think we'll have much extra documentation (You can always test and share your findings here, from my initial test any other number results in the same behavior as 11).
You could hack your way around this by using a DATE_ADD or DATE_SUB to move your actual date a couple of days so that the displaced calendar would align with weeks Sat-Fri, but this becomes tricky when you approach the beginning or end of the year.
YEARWEEK(DATE_ADD(`dt`,INTERVAL 1 DAY),11)
Will give you weeks starting on Saturday, but as explained if might work weirdly towards the start or end of a year. In here you can see that it considers 12/31/2022 as Week 202301.
1 -
Thanks so much for this! I was seeing similar behavior regardless of the code I entered for the mode value. I was hoping I was missing something obvious - oh well. I will check with the team and see whether a consistent Sunday-Saturday week definition is okay or whether we should look at your workaround.
Thanks again!
0 -
I've also had issues the YEARWEEK() function not working as it should in BeastModes. However, it is worth noting that the same function (name, anyway) works perfectly, as expected in MagicETL. I've opened a support ticket (case: 05895315) about this. MagicETL leverages native MySQL, which is why YEARWEEK() works as it should in ETLs. The version available in BeastMode is something DOMO engineers stubbed out for us, but it has bugs and should be updated to use or match the native MySQL YEARWEEK() functionality.
0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 302 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 637 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 762 Beast Mode
- 65 App Studio
- 42 Variables
- 704 Automate
- 182 Apps
- 458 APIs & Domo Developer
- 53 Workflows
- 11 DomoAI
- 39 Predict
- 16 Jupyter Workspaces
- 23 R & Python Tiles
- 401 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 8 Software Integrations
- 133 Manage
- 130 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive