Domo IDEAs Conference - Beast Modes - Add Business Days
GrantSmith
Coach
in Magic ETL
Greetings! This is another post highlighting a beast mode from my Domo IDEAs conference session. This one covers how to add a specific number of business days into the future.
Problem:
How do I add a specific number of business days?
Solution:
We convert the number of business days into the actual days. Convert the number of business days into full weeks and multiply by 7 to get the total days. Then add the remaining days and some extra days if we cross over a weekend.
-- Author: -- Created: -- Last Modified: -- Description: Add 6 business days to the specific date in the `dt` field. -- NOTE: This is a lazy calculation which doesn't take into account holidays or other days -- the business may be closed. -- ALSO - This assumes M-F as the work week. `dt` + -- Calculate the number of days. in this example replace 6 with the number of business days to add INTERVAL ( -- Calculate the number of weeks in the number of business days FLOOR(6/5) * 7 -- If the remaining number of days (MOD) would take us past Saturday then add 2 days to get over the weekend. + CASE WHEN MOD(6,5) + DAYOFWEEK(`dt`) >= 7 THEN 2 - -- This returns either 1 if the date is a Saturday otherwise 0 -- Does the date start on saturday? If so we only need to add 1 (2-1=1) days to get over the weekend instead of 2. FLOOR(DAYOFWEEK(`dt`)/7) ELSE 0 END -- Add the remaining number of work days after taking into account full weeks + MOD(6,5)) DAY
Notes:
This assumes any Monday-Friday is a business day and doesn't handle Holidays or days the business may be closed.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**
**Did this solve your problem? Accept it as a solution!**
2
Comments
-
Here's a link to the video of my session outlining this beast mode: https://www.youtube.com/watch?v=gO8OLpsAk4M&index=6
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 302 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 633 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 760 Beast Mode
- 62 App Studio
- 42 Variables
- 699 Automate
- 181 Apps
- 457 APIs & Domo Developer
- 51 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 401 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 8 Software Integrations
- 130 Manage
- 127 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