Astroraf
07-22-2024Data Pipeline
Extract Date Format from Date Column using Extract?
I am trying to extract the DAY, MONTH, YEAR from a date column from my date column to create a dim_date table in my model.
Currently my code goes as follows:
SELECT
DISTINCT birthdate AS Date,
YEAR(birthdate) AS Year,
MONTH(birthdate) AS Month,
DAY(birthdate) AS Day
FROM FACT_table
UNION
SELECT
DISTINCT hire_date AS Date,
YEAR(hire_date) AS Year,
MONTH(hire_date) AS Month,
DAY(hire_date) AS Day
FROM FACT_table
I get this error: Function 'YEAR(DateTime)' is not declared. What is the right syntax to extract the various DATE formats from a column from a fact table?
Hey Astroraf are you doing this in a custom table (green node in the elasticube)? If so the syntax is GETYEAR(yourdate),
GETMONTH(yourdate),
GETDAY(yourdate)