Best Practice for Date fields
Hi All,
I did a quick search on this but could not find much. If I missed something, please feel free to direct me to the appropriate resource.
I work for a Support organization where our data sources have a lot of date fields, think of fields such as Ticket_created_at, Ticket_resolved_at, Ticket_first_response_at. I want to build cards with Time to Resolution, Time to First Response, etc.
Here are my questions and request for advice:
1. Should these calculations happen on the Dataflow level or in the cards?
2. If it is to happen on the Dataflow level, how could I best standardize the data format?
Thank you for any help/insight!
Comments
-
@mynameisyannis I typically do these kinds of aging calcs in beast mode. Just seems more simple to build the banding the way you want and update quickly. I would handle the field formatting ahead of the card building layer. Here's an example:
Age Banding:
CASE
When DATEDIFF(CURDATE(),`Order Date`) >=120 then '> 120'
When DATEDIFF(CURDATE(),`Order Date`) >=90 then '90-120'
When DATEDIFF(CURDATE(),`Order Date`) >=60 then '60-90'
When DATEDIFF(CURDATE(),`Order Date`) >=30 then '30-60'
When DATEDIFF(CURDATE(),`Order Date`) < 30 then '< 30'END
Age Banding Sort:
CASE
When DATEDIFF(CURDATE(),`Order Date`) >=120 then 5
When DATEDIFF(CURDATE(),`Order Date`) >=90 then 4
When DATEDIFF(CURDATE(),`Order Date`) >=60 then 3
When DATEDIFF(CURDATE(),`Order Date`) >=30 then 2
When DATEDIFF(CURDATE(),`Order Date`) < 30 then 1END
0 -
Thanks @swagner!
Will definitely give that a go! And how about the date columns?Currently, CURDATE() and my date columns are in different formatting (think of US/UK format).
1. What's the best way to standardize my date columns? In beast mode or when I am building the dataflow?
2. What SQL function is better for this?
Thank you!
0 -
@mynameisyannis to be honest, not sure on how to handle the date format in SQL for your use case. You can probably find on stack overflow - or maybe even a google search.
There are also ways to manage date formats in Magic ETL (I use often) where you can specify the "MM-DD-YYYY" vs "DD-MM-YYYY" differences.
0 -
If at data ingestion, Domo is able to 'interpret' your data as type Date, it will store it as type date and then display it in the correct format (day first or month first) as appropriate. So your question of CurDate() and date columns being in different formats should not apply.
If Domo is presenting your Date columns as type Text, then it suggests that at data ingestion there were values that prevented Domo from interpreting the data as type Column. Usually that implies invalid values not just a formatting problem.
That said, if you're uploading DateTime, then Domo can be a little tricky to work with and that might require massaging to sort out.
In terms of best practices, I usually avoid uploading DateTime columns unless the Time is absolutely necessary, in which case, I usually recommend splitting Date and Time into separate columns because dealing with TimeZones and Datelight Savings is a huge pita, AND cards will be more performant on just a Date column (as opposed to DateTime) due to Adrenaline's ability to compress and index the data more efficiently (fewer cardinal values).
If possible, I would actually avoid calculating dateDiffs and other derived measures in ETL because 1) it gives you flexibility if you need to change the math, by implementing in BeastModes (and it gives the benefit of transparency... for data governance you can use the Domo Governance datasets and the beast mode manager to create some sort of data dictionary).
2) I believe the dateDiff implementation in MagicETL can be a little janky and therefore requires investigation if the timediff exceeds 24 hours, I think @DataMaven knows a bit more on this topic (but deffo Unix Timestamp is the best option that works all the time).
For calculating time or date diff, I think @GrantSmith did all the hard work on this one and concluded that it's best to convert the dateTime column into UNIX timestamp first and then do the diff of UnixTimeStamp because that guarantees to return the number of seconds between the two dateTimes (which you can then math into the desired units).
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"1 -
@mynameisyannis - To follow up on @jaeW_at_Onyx 's dealing with UNIX_TIMESTAMP I've outlined usage and math to get days, hours, minutes and seconds in another post here: https://dojo.domo.com/t5/Beast-Mode-ETL-Dataflow/Date-Calculations-minutes-and-seconds/m-p/49259/highlight/true#M8465
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive