Convert text to date field using
Hello,
I am using Magic ETL and trying to convert a text field to a date field.
Earlier on my data flow I had to alter some columns by using the cast function.
I was able to continue with the data flow and have the output I want. It was until I was creating a card that I noticed the "Date" is "Text". (I have some formulas and rename the column "RRDAT" to Month"
When I try to do my cards, I don't have the time range to select the time frame for my chart
Any idea how I can convert this "Month" column from text to date?
Best Answers
-
Since your field only contains the month and the year, I recommend using the split_part and concat function to pull out the month and year and set it to the 1st of the month. You can do it like this:
DATE(CONCAT(split_part(Monthfield,'-',1),'/1/',split_part(Monthfield,'-',2)))
Wrapping the DATE() function around all of it will convert it to a date field after it has built the date.
**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 -
First I would make sure that the column is included in the select columns tile at the end of the ETL. Next, I would edit the card in Analyzer and click on the Date Range selector in the top right. Ensure that Hide Date on Card Details is not selected and that the appropriate Date Range Field is selected.
**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 Mark and Grand for your support, I was able to get the Data Range on my chart, it appears I didn't have all the columns selected at the end of the ETL.
1
Answers
-
You can use a formula tile and the STR_TO_DATE function
STR_TO_DATE(`Month`, '%Y-%m')
Alternatively you could just use LAST_DAY to get the last day of a month to get the month of your date / timestamp field.
LAST_DAY(`RRDAT`)
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Still missing something, when I validate the formula shows that it is valid, but I get the error message.
I can not use your second suggestion as 'RRDAT' was rename.
0 -
Sorry, I had the wrong format, try
%m-%Y
.**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
still not working, getting the same error
0 -
Since your field only contains the month and the year, I recommend using the split_part and concat function to pull out the month and year and set it to the 1st of the month. You can do it like this:
DATE(CONCAT(split_part(Monthfield,'-',1),'/1/',split_part(Monthfield,'-',2)))
Wrapping the DATE() function around all of it will convert it to a date field after it has built the date.
**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 Mark, for the suggestion, so the formula works, but when I try to visualize the data by creating a card I don't see the date range at the top of my chart, see below chart.
I want to be able to have the "date range" option.
I haven't been able to find a way to add this option to my card.
0 -
First I would make sure that the column is included in the select columns tile at the end of the ETL. Next, I would edit the card in Analyzer and click on the Date Range selector in the top right. Ensure that Hide Date on Card Details is not selected and that the appropriate Date Range Field is selected.
**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 Mark and Grand for your support, I was able to get the Data Range on my chart, it appears I didn't have all the columns selected at the end of the ETL.
1 -
@Newbie23 glad we could help. If you can mark any answers that helped you as accepted, that will help others in the community.
**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
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