Date Conversion

Best Answers
-
You can get this formatted as a date field by using the STR_TO_DATE() function like this:
STR_TO_DATE(yourfield, '%a, %d %b %Y %h:%i %p')
You can use the monthname function around this function to extract the month name, but that will be a string value since it is text.
**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.1 -
You can do this, but its going to add '1, 0001' for days and year.
STR_TO_DATE(MONTHNAME(
[your date column]
), '%M')Can you explain why you need it to be a date column? Maybe there is a round about way to achieve what you're trying
0 -
Hi @TMonty0319,
This should do the trick:
DATE_FORMAT(STR_TO_DATE(TRIM(SUBSTRING(<your date field>,INSTR(<your date field>,',')+1)), '%d %b %Y %H:%i %p'),'%Y-%m-%d %H:%i:%s')
This finds the first occurrence of the comma in your string and removes the day abbreviation since you dont really need that (since the day month and year follow it). We then trim it to remove any leading/trailing spaces and apply STR_TO_DATE to convert it to a datetime. However that leaves you with a unix style timestamp. So we then apply ISO date format to normalize it to a standard datetime using DATE_FORMAT. I hope this helps
0
Answers
-
You can get this formatted as a date field by using the STR_TO_DATE() function like this:
STR_TO_DATE(yourfield, '%a, %d %b %Y %h:%i %p')
You can use the monthname function around this function to extract the month name, but that will be a string value since it is text.
**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.1 -
You can do this, but its going to add '1, 0001' for days and year.
STR_TO_DATE(MONTHNAME(
[your date column]
), '%M')Can you explain why you need it to be a date column? Maybe there is a round about way to achieve what you're trying
0 -
Hi @TMonty0319,
This should do the trick:
DATE_FORMAT(STR_TO_DATE(TRIM(SUBSTRING(<your date field>,INSTR(<your date field>,',')+1)), '%d %b %Y %H:%i %p'),'%Y-%m-%d %H:%i:%s')
This finds the first occurrence of the comma in your string and removes the day abbreviation since you dont really need that (since the day month and year follow it). We then trim it to remove any leading/trailing spaces and apply STR_TO_DATE to convert it to a datetime. However that leaves you with a unix style timestamp. So we then apply ISO date format to normalize it to a standard datetime using DATE_FORMAT. I hope this helps
0 -
I just need the month name. So from this - Thu, 29 Feb 2024 11:59 PM i need a formula for a new column that just has February and is in Date Format.
0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 310 Workbench
- 7 Cloud Amplifier
- 9 Federated
- 3K Transform
- 114 SQL DataFlows
- 654 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 796 Beast Mode
- 78 App Studio
- 44 Variables
- 757 Automate
- 188 Apps
- 480 APIs & Domo Developer
- 72 Workflows
- 17 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 408 Distribute
- 119 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 141 Manage
- 137 Governance & Security
- 8 Domo Community Gallery
- 47 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive