I need to convert a text column to date in ETL
Best Answers
-
If you have garbage data which doesn't match your date format ('Day' in your example) it may not be simple enough to just convert it to a date. You may need to conditionally set your date value:
CASE WHEN REGEXP_LIKE(`date_field`, '^\d{4}-\d{2}-\d{2}$') THEN STR_TO_DATE(`date_field`, '%Y-%m-%d') END
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
You can also use TRY_CAST(myfield as date) this will null the value if it can't convert it to a date, otherwise it will make it a date formatted value.
**Check out my Domo Tips & Tricks Videos
**Make sure toany users posts that helped you.
**Please mark as accepted the ones who solved your issue.0
Answers
-
If you have garbage data which doesn't match your date format ('Day' in your example) it may not be simple enough to just convert it to a date. You may need to conditionally set your date value:
CASE WHEN REGEXP_LIKE(`date_field`, '^\d{4}-\d{2}-\d{2}$') THEN STR_TO_DATE(`date_field`, '%Y-%m-%d') END
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
You can also use TRY_CAST(myfield as date) this will null the value if it can't convert it to a date, otherwise it will make it a date formatted value.
**Check out my Domo Tips & Tricks Videos
**Make sure toany users posts that helped you.
**Please mark as accepted the ones who solved your issue.0
Categories
- All Categories
- 1.2K Product Ideas
- 1.2K Ideas Exchange
- 1.3K Connect
- 1.1K Connectors
- 273 Workbench
- Cloud Amplifier
- 3 Federated
- 2.7K Transform
- 78 SQL DataFlows
- 524 Datasets
- 2.1K Magic ETL
- 2.9K Visualize
- 2.2K Charting
- 433 Beast Mode
- 22 Variables
- 510 Automate
- 114 Apps
- 388 APIs & Domo Developer
- 8 Workflows
- 26 Predict
- 10 Jupyter Workspaces
- 16 R & Python Tiles
- 331 Distribute
- 76 Domo Everywhere
- 255 Scheduled Reports
- 65 Manage
- 65 Governance & Security
- 1 Product Release Questions
- Community Forums
- 40 Getting Started
- 26 Community Member Introductions
- 67 Community Announcements
- 4.8K Archive