How to Extract the Year from a Date in Snowflake
A practical review of the ways to pull the year out of a date or timestamp in Snowflake: YEAR, EXTRACT, DATE_PART, DATE_TRUNC and TO_CHAR, with their output types, time zone and week-year caveats.
Pulling the year out of a date is one of the most common transformations in Snowflake SQL. Several built-in functions can do it, and they mostly agree on ordinary calendar dates. They differ in what they return: a number, a date or a string. That choice affects sorting, joins, exports and how downstream tools display the value. This review explains what each approach changes and when each one fits.
Scope note: no tool-specific test results, benchmarks or measurements were supplied for this article. The behavior described below follows Snowflake's documented function semantics and general SQL principles. Account settings can change results, so confirm against the current Snowflake documentation and your own session parameters before you rely on edge cases.
Short answer: which approach suits your use?
For most analytical work, use YEAR(date_column) or the equivalent EXTRACT(YEAR FROM date_column). Both return an integer, which sorts numerically, compares cheaply and groups cleanly. The tradeoff is that the result is no longer a date, so you lose date arithmetic and date-aware filtering on that column. If you need to keep a real date, for example for a time-series axis or a join to a calendar table keyed on dates, use DATE_TRUNC('YEAR', date_column) instead. It returns January 1 of the same year.
Plain text output from TO_CHAR(date_column, 'YYYY') is preferable only when the destination expects a string. Examples include concatenating labels, building file names, or exporting to a system that treats every field as text. Avoid it when you need numeric comparison or aggregation.
The main options compared
| Function | Example | Result | Result type | Best for |
| YEAR | YEAR('2024-03-15'::DATE) | 2024 | Number | Grouping, filtering and numeric comparison |
| EXTRACT | EXTRACT(YEAR FROM '2024-03-15'::DATE) | 2024 | Number | Portable, standard-style SQL |
| DATE_PART | DATE_PART('YEAR', '2024-03-15'::DATE) | 2024 | Number | Code that selects the date part dynamically or by name |
| DATE_TRUNC | DATE_TRUNC('YEAR', '2024-03-15'::DATE) | 2024-01-01 | Date | Keeping a true date for charts, joins and date math |
| TO_CHAR | TO_CHAR('2024-03-15'::DATE, 'YYYY') | '2024' | String | Labels, concatenation and text-only destinations |
SELECT
order_date,
YEAR(order_date) AS order_year,
EXTRACT(YEAR FROM order_date) AS order_year_extract,
DATE_TRUNC('YEAR', order_date) AS order_year_start,
TO_CHAR(order_date, 'YYYY') AS order_year_text
FROM orders;
What the transformation actually changes
Extracting the year is a lossy, stored-value change. When you select or persist the result, month, day and time-of-day information is discarded. Two different source dates in the same year become indistinguishable. Nothing here is a display effect: the new column holds a different value of a different type. Keep the original date column alongside the derived year whenever later steps might need finer detail.
The type change matters as much as the information loss:
- YEAR, EXTRACT and DATE_PART produce a number. Numbers sort as 1999, 2000, 2024 and can be compared with greater-than or less-than.
- DATE_TRUNC keeps the date type. It rounds down to the first day of the year, so date functions, date ranges and calendar joins still work.
- TO_CHAR produces text. Four-digit years happen to sort correctly as strings, but comparing a string year to a numeric year requires a cast, and mixing the two types in joins can cause mismatches or implicit conversions.
Inputs that need care
Dates stored as strings
If the source column is VARCHAR, convert it explicitly before extracting the year. TO_DATE with an explicit format raises an error on values that do not match. TRY_TO_DATE returns NULL instead, which lets you find bad rows rather than stopping the query. Relying on implicit conversion depends on the input format and session settings, so an explicit format is the safer choice.
SELECT
raw_date,
YEAR(TRY_TO_DATE(raw_date, 'MM/DD/YYYY')) AS parsed_year
FROM staging_events
WHERE TRY_TO_DATE(raw_date, 'MM/DD/YYYY') IS NOT NULL;
Timestamps and time zones
Year extraction works on timestamps as well as dates, but the result depends on which local time the timestamp is interpreted in. A moment shortly after midnight UTC on January 1 is still December 31 in US time zones. TIMESTAMP_LTZ values are evaluated in the session time zone. TIMESTAMP_TZ values carry their own offset. TIMESTAMP_NTZ has no time zone at all. If year boundaries matter, for example in fiscal or regulatory reporting, convert to the intended time zone first, such as with CONVERT_TIMEZONE, and then extract the year.
Calendar year versus week-based year
Snowflake also offers YEAROFWEEK and YEAROFWEEKISO, which return the year that a date's week belongs to. These can differ from the calendar year near year boundaries. Under ISO rules, December 30, 2024 falls in week 1 of 2025, so YEAROFWEEKISO returns 2025 while YEAR returns 2024. YEAROFWEEK depends on the account's week-related parameters (WEEK_START and WEEK_OF_YEAR_POLICY), so results can vary between environments. Use these functions only when you report by week. Pair them with the matching week function so the year and week stay consistent.
SELECT
YEAR('2024-12-30'::DATE) AS calendar_year, -- 2024
YEAROFWEEKISO('2024-12-30'::DATE) AS iso_week_year, -- 2025
WEEKISO('2024-12-30'::DATE) AS iso_week; -- 1
NULL values
All of these functions return NULL when the input is NULL. If downstream logic treats a missing year differently from a real one, handle that explicitly, for example with COALESCE or a filter. Do not let NULLs fall silently into an unnamed group.
Will the result stay usable after export or sharing?
A numeric year exported to CSV or copied out of a result grid is just a sequence of digits, which nearly any destination can read. The common problem is presentation, not the stored value. Some spreadsheet and reporting tools apply default number formatting to numeric columns and may show a year with a thousands separator. No specific destination was tested for this article, so check the formatting of the year column in your own tool. If you cannot control formatting there, exporting the year as text with TO_CHAR avoids the issue, at the cost of numeric behavior.
Readability and accessibility are not a concern in the sense they are for styled or reversed text. The output is ordinary digits, so screen readers, search and editing treat it like any other number or date. The practical risks are type mismatches between systems and the information you discarded. A plain date value is the better thing to share when recipients may need the month or day, or when they will filter by date ranges themselves.
Recommendation in brief
- Default: YEAR(col) or EXTRACT(YEAR FROM col) for grouping, filtering and comparing by year.
- Need a real date: DATE_TRUNC('YEAR', col).
- Need text: TO_CHAR(col, 'YYYY'), only for labels or text-only destinations.
- Weekly reporting: YEAROFWEEKISO with WEEKISO, after confirming week parameters if you use the non-ISO versions.
- String or timestamp input: convert explicitly and set the time zone before extracting.
- Keep the original date column whenever later steps might need the detail you are removing.