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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 737 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive