SnowConvert AI - ANSI SQL - Interval Data Types¶
Description¶
The INTERVAL data type represents a duration or period of time. Many SQL dialects support INTERVAL types in column definitions, literals, and arithmetic expressions. Snowflake supports two families of INTERVAL types: INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND. Learn more from the Snowflake documentation: INTERVAL Data Type.
Warning
The Snowflake INTERVAL data type is currently in Public Preview. The transformations described on this page require the --UseIntervalDatatype preview flag to be enabled. Without this flag, INTERVAL types are converted to VARCHAR as described in each language’s data type reference.
Snowflake Interval Types¶
Snowflake supports two interval qualifier families. Mixed qualifiers (combining year-to-month and day-to-second parts) are not allowed.
Qualifier Family |
Supported Qualifiers |
|---|---|
Year-to-Month |
|
Day-to-Second |
|
Language Behavior Summary¶
Source Language |
Qualifier Handling |
Notes |
|---|---|---|
Oracle, Teradata |
Source qualifiers preserved |
These languages use explicit INTERVAL qualifiers that map directly to Snowflake |
Redshift, Spark, Databricks, Vertica |
Source qualifiers preserved |
Same as above |
BigQuery, PostgreSQL, Greenplum, Netezza |
Normalized to |
Bare |
SQL Server, DB2 |
Qualifiers preserved where applicable |
Limited native INTERVAL support in source language |
Interval Column Type Transformations¶
When the --UseIntervalDatatype flag is enabled, INTERVAL columns in CREATE TABLE statements are preserved as native Snowflake INTERVAL types.
Languages with explicit qualifiers¶
For Oracle, Teradata, Redshift, Spark, Databricks, and Vertica, the source INTERVAL qualifier is preserved directly.
Source (Oracle)¶
Snowflake¶
Languages with unqualified INTERVAL¶
For BigQuery, PostgreSQL, Greenplum, and Netezza, bare INTERVAL is normalized to INTERVAL DAY TO SECOND with SSC-FDM-0042.
Source (BigQuery)¶
Snowflake¶
Without the flag (default behavior)¶
Without the --UseIntervalDatatype flag, INTERVAL columns are converted to VARCHAR(30) with SSC-EWI-0036.
Interval Literal Transformations¶
When the flag is enabled, interval literals are normalized to Snowflake-compatible INTERVAL literal syntax. The normalization depends on the source dialect.
ANSI standard literals¶
Standard ANSI interval literals with explicit qualifiers are preserved as-is across all languages.
Source (Oracle, Teradata, Redshift)¶
Snowflake¶
Verbose syntax normalization¶
PostgreSQL, Redshift, Vertica, Greenplum, Netezza, and Spark support verbose interval syntax with named units (for example, WEEK, DAY, HOUR). These are normalized to compact Snowflake INTERVAL literals.
Source (PostgreSQL)¶
Snowflake¶
ISO 8601 format normalization¶
PostgreSQL and related languages support ISO 8601 duration format. These are normalized to compact Snowflake literals.
Source (PostgreSQL)¶
Snowflake¶
BigQuery expression intervals¶
BigQuery supports computed interval expressions (INTERVAL expr unit). These are transformed to CAST expressions.
Source (BigQuery)¶
Snowflake¶
Overflow normalization¶
Teradata interval literals with overflowing values are normalized to valid Snowflake intervals.
Source (Teradata)¶
Snowflake¶
Negative sign normalization¶
Teradata places the negative sign outside the literal string. SnowConvert AI normalizes it inside the string for Snowflake compatibility.
Source (Teradata)¶
Snowflake¶
AGO keyword handling¶
PostgreSQL and related languages support the AGO keyword to negate an interval. SnowConvert AI resolves this into a negated Snowflake interval literal.
Source (PostgreSQL)¶
Snowflake¶
Spark multi-unit intervals¶
Spark supports multi-unit interval literals with mixed positive and negative components. These are normalized to compact Snowflake form.
Source (Spark)¶
Snowflake¶
Vertica named-unit intervals¶
Vertica supports named-unit interval syntax that is normalized to compact Snowflake form.
Source (Vertica)¶
Snowflake¶
Interval Arithmetic¶
When the flag is enabled, datetime subtraction expressions that produce interval results are transformed to use Snowflake’s native interval types.
Year-to-Month family¶
Datetime subtraction with YEAR, MONTH, or YEAR TO MONTH qualifiers uses TIMESTAMPDIFF and CAST to produce a native interval result.
Source (Oracle, Teradata)¶
Snowflake¶
Day-to-Second family¶
Datetime subtraction with DAY, HOUR, MINUTE, SECOND, or compound qualifiers uses direct timestamp subtraction, producing a native interval result.
Source (Oracle, Teradata)¶
Snowflake¶
DATE operand handling¶
When DATE operands are used in interval subtraction, they are wrapped with TIMESTAMP_NTZ_FROM_PARTS to produce a timestamp suitable for interval subtraction.
Source (Oracle)¶
Snowflake¶
CAST to Interval¶
CAST expressions targeting interval types are preserved when the flag is enabled.
Source (Teradata)¶
Snowflake¶
Interval Arithmetic with Existing Columns¶
Standard interval arithmetic with columns and literals (addition, subtraction, multiplication, division) is preserved as-is.
Source (Oracle, Teradata, Redshift)¶
Snowflake¶
Oracle Precision Zero Handling¶
Oracle allows INTERVAL types with precision (0), which has no equivalent in Snowflake. SnowConvert AI removes the zero precision qualifier.
Source (Oracle)¶
Snowflake¶
Known Limitations¶
The following scenarios produce warnings when the --UseIntervalDatatype flag is enabled:
Dynamic Tables (SSC-EWI-0118): Snowflake does not support INTERVAL columns in Dynamic Tables. The Dynamic Table is still generated with a warning.
UDFs and Snowflake Scripting (SSC-EWI-0117): Snowflake does not support the INTERVAL data type in UDF/procedure parameters, return types, or variable declarations.
Semi-structured types (SSC-EWI-0116): Snowflake does not support INTERVAL values inside VARIANT, ARRAY, MAP, or STRUCT columns.
Qualifier normalization (SSC-FDM-0042): For languages with unqualified or mixed INTERVAL types, the qualifier is changed to
DAY TO SECOND.