# How to get the min date of a date that is stored as an int in dbt + snowflake?

**URL:** <https://discourse.getdbt.com/t/how-to-get-the-min-date-of-a-date-that-is-stored-as-an-int-in-dbt-snowflake/8192>\
**Category:** Help\
**Created:** [May 8, 2023, 7:54pm UTC](https://discourse.getdbt.com/t/how-to-get-the-min-date-of-a-date-that-is-stored-as-an-int-in-dbt-snowflake/8192 "2023-05-08T19:54:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![acvribeiro](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/acvribeiro/32/3746_2.png) [@acvribeiro](https://discourse.getdbt.com/u/acvribeiro)\
**Post date:** [May 8, 2023, 7:54pm UTC](https://discourse.getdbt.com/t/how-to-get-the-min-date-of-a-date-that-is-stored-as-an-int-in-dbt-snowflake/8192/1 "2023-05-08T19:54:33Z")

</div>

I am working with dbt + SNOWFLAKE.

I have a column called “Event\_Name”, which is a date that comes as an int.

> 20230101

I’ve made the following model and I’ve tested it with hardcoded dates to make sure I got the function right.  
However, when I want to point the start\_date to the min Event\_Date, I get the following error:

```auto

17:18:04 252005: Failed to convert current row, cause: Python int too large to convert to C int

```

This is the model:

```auto

{{ config(
      alias='DIM_DATE',
      materialized = "table"
) }}

{% set get_min_date_query %}
    select min(event_date::varchar) 
    from {{ ref('raw_events_pivot') }}
{% endset %}
{% set min_query_result = run_query(get_min_date_query) %}

{% if execute %}
 {% set min_year_result = min_query_result.columns[0].values()[0] %}
{% else %}
    set min_year_result = 0
{% endif %}  
{% set start_date = get_start_date(min_year_result ) %}
 

with date_create as (
{{ dbt_date.get_date_dimension( start_date , '2023-12-31' )}}
) 

SELECT
    DATE_DAY AS date,
    YEAR_NUMBER as year,
    DAY_OF_WEEK_NAME_SHORT as day_name,
    WEEK_OF_YEAR,
    'WK' || WEEK_OF_YEAR || '-' || YEAR_NUMBER as week_year, --WK52-2022
    MONTH_OF_YEAR as month_nr,
    MONTH_NAME,
    MONTH_NAME_SHORT,
    QUARTER_OF_YEAR as quarter,
    'Q'|| QUARTER_OF_YEAR || '-' || YEAR_NUMBER AS quarter_year, --Q1-2023
    current_user() as INT_LoadBy,
    sysdate() as INT_UPDATETIMESTAMPUTC,
    'DBT' as COD_IntSourceSystem
FROM Date

```

What am I supposed to do to fix this?  
I even tried to convert the start date to char but I didn’t get it…
