How to extract Date from TimeStamp1, Time from TimeStamp2, and then combine the two?
So I have two fields, "DateV2" and "EventTime V2". I am trying to extract out the Date portion (2018-11-16) from "DateV2" and combining that with the Time portion (12:07:00) from "EventTime V2".
I am trying to do this in Magic 2.0.
Here is my beast mode/formula in the Formula Tile:
DATE_FORMAT(CONCAT(DATE_FORMAT(`Date V2`,'%Y-%m-%d'), ' ', DATE_FORMAT(`EventTime V2`,'%H:%i:%s' )),'%Y-%m-%d %H:%i:%s') ELSE `Date V2` END
The preview of the formula works. However, when I try to run this, I run into an error:
I am not sure why the preview works when it is able to recognize 18:00:00 as a timestamp but 15:40:00 (in the error) does not work.
Anyone spot anything wrong? Or, is there a simpler way of extracting these two parts out and combining them?
Appreciate any help, thank you!
Best Answer
-
Try this:
Use the DATE() function to extract the date from the field you want just the date
Use the TIME() function to extract the time from the field you want just the time
Use the ADDTIME() function to add the two together ADDTIME('dt','tm')
I did a quick test in Magic ETL and it worked for me. I had them each separated for testing, but you should be fine wrapping it all into one like this:
ADDTIME(DATE('datefield',),TIME('timefield'))
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1
Answers
-
Try this:
Use the DATE() function to extract the date from the field you want just the date
Use the TIME() function to extract the time from the field you want just the time
Use the ADDTIME() function to add the two together ADDTIME('dt','tm')
I did a quick test in Magic ETL and it worked for me. I had them each separated for testing, but you should be fine wrapping it all into one like this:
ADDTIME(DATE('datefield',),TIME('timefield'))
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1 -
Thanks for the help -- that is definitely simpler and easier to follow!
I realized that the "EventTime V2" field I was referencing in my original beast mode was NOT datetime, but rather a string (due to an earlier transformation).
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
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 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