TimeSpan formatting function


There have been a lot of requests on the Dojo about specific formatting for the difference between two dates. It'd be great if there was as simple function we could pass in a time diff (`Date2` - `Date1`) along with a format string to automatically calculate the correct display string.
For example:
FORMAT_DIFF(`Date2` - `Date1`, '%W weeks, %d days')
DATEDIFF only gives us a single unit of measure but a lot of times we'll want a combination of units (Week + Days, Years + Months + Days, Hours + Minutes + Seconds)
Right now the common solution is to utilize UNIX_TIMESTAMP and calculating the difference in seconds between the two and then doing a bunch of math depending on which unit you need which can become very complex and difficult to understand if you're not technical enough.
**Did this solve your problem? Accept it as a solution!**
Comments
-
Does this exist in any other SQL implementation?
i guess on paper it's pretty, but the challenge then is that the output would be a text string. that text string would not (necessarily) be sortable, and relatively difficult to work with. if you wanted for example "where timediff is between 12 and 15 days" but all the values are long strings.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
- 10.5K All Categories
- 6 Connect
- 916 Connectors
- 250 Workbench
- 463 Transform
- 1.7K Magic ETL
- 69 SQL DataFlows
- 476 Datasets
- 189 Visualize
- 252 Beast Mode
- 2.1K Charting
- 11 Variables
- 17 Automate
- 354 APIs & Domo Developer
- 89 Apps
- 3 Workflows
- 20 Predict
- 5 Jupyter Workspaces
- 15 R & Python Tiles
- 246 Distribute
- 62 Domo Everywhere
- 243 Scheduled Reports
- 21 Manage
- 42 Governance & Security
- 172 Product Ideas
- 1.2K Ideas Exchange
- 11 Community Forums
- 27 Getting Started
- 14 Community Member Introductions
- 55 Community News
- 4.5K Archive