Day of Year in Redshift

Does Domo's Redshift support day of year?
I'm trying to parse my date column using the formulas and none work:
date_part(doy, "date") as "day of year"
date_part(dy, "date") as "day of year"
date_part(yearday, "date") as "day of year"
date_part(dayofyear, "date") as "day of year"
In the Redshift documentation this should work: https://docs.aws.amazon.com/redshift/latest/dg/r_Dateparts_for_datetime_functions.html
Best Answer
-
Another date function you can use in Redshift is Extract. I use it and it looks like this:
extract(year from "dateofevent") DateofEventYear,
extract(day from "dateofevent") DayofEvent,I am able to use the date_part function as @jaeW_at_Onyx suggests, so I'm not sure what might be going on with that function in your instance, but maybe you will have better luck with the Extract function.
**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
-
What error message did you get? This works fine.
select date_part(dayofyear, cast('2020-02-14' as date))
Is your Date column a date or text?
Domo processes Redshift ETL in a Redshift cluster. So if you're throwing an error during transform steps it's usually a code issue.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
select *,
date_part(y,"date") as "year",
(case when date_part(q,"date") <= 2 then 1 else 2 end) as "half year",
date_part(q,"date") as "quarter",
date_part(m,"date") as "month",
date_part(dayofyear, "date") as "day of year"
from "group_by"Date is a date field, not text. It wasn't throwing an error for any of the other date_part functions in this query.
0 -
Another date function you can use in Redshift is Extract. I use it and it looks like this:
extract(year from "dateofevent") DateofEventYear,
extract(day from "dateofevent") DayofEvent,I am able to use the date_part function as @jaeW_at_Onyx suggests, so I'm not sure what might be going on with that function in your instance, but maybe you will have better luck with the Extract function.
**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 -
The database reported a syntax error: [Amazon](500310) Invalid operation: Invalid datetime part in DATE_PART(). Details: ----------------------------------------------- error: Invalid datetime part in DATE_PART(). code: 8001 context: query: 8206522 location: datetime
That's the error I'm getting. it's from the dayofyear line of the query.
0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 656 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive