# Datediff - dict object errors - dbt upgrades

**URL:** <https://discourse.getdbt.com/t/datediff-dict-object-errors-dbt-upgrades/6893>\
**Category:** Help\
**Tags:** dbt-cloud\
**Created:** [February 21, 2023, 9:08am UTC](https://discourse.getdbt.com/t/datediff-dict-object-errors-dbt-upgrades/6893 "2023-02-21T09:08:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pks3](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@pks3](https://discourse.getdbt.com/u/pks3)\
**Post date:** [February 21, 2023, 9:08am UTC](https://discourse.getdbt.com/t/datediff-dict-object-errors-dbt-upgrades/6893/1 "2023-02-21T09:08:03Z")

</div>

Recently, upgraded my dbt to v1.3 and facing some issues with a few macros but a new compilation error keeps coming for datediff or datespine , which is not working out

Error message:

```auto
09:29:41 Compilation Error in model android_track_sessionized
09:29:41 'dict object' has no attribute 'datediff'. This can happen when calling a macro that does not exist. Check for typos and/or install package dependencies with "dbt deps".

```

– Same error shows up for datespine too, when changed

## The context of why I’m trying to do this

I’m trying to fix this so that my sessionization code works out  
Source: [segment/models/sessionization/segment\_web\_page\_views\_\_sessionized.sql at main · dbt-labs/segment · GitHub](https://github.com/dbt-labs/segment/blob/main/models/sessionization/segment_web_page_views__sessionized.sql)

My packages look like this :  
packages:  
- package: dbt-labs/dbt\_utils  
version: “1.0.0”

## What I’ve already tried

Tested a few new macros like datespine, but the same error shows up. Also the macro does exist in dbt-utils too - so not sure what’s causing it.

> <https://github.com/dbt-labs/dbt-utils/blob/main/macros/sql/date_spine.sql>

Code part that causes errors: -

```auto
diffed AS (
    --calculates `period_of_inactivity`.
    SELECT
        *,
        {{ dbt_utils.datediff(
            'previous_tstamp',
            'timestamp',
            'second'
        ) }} AS period_of_inactivity
    FROM
        lagged

```

Would appreciate any directional help here, curious if I should upgrade to v1.4 dbt or add a new macro definition

---

<div class="post-metadata">

**Author:** ![pks3](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@pks3](https://discourse.getdbt.com/u/pks3)\
**Post date:** [February 22, 2023, 7:00am UTC](https://discourse.getdbt.com/t/datediff-dict-object-errors-dbt-upgrades/6893/2 "2023-02-22T07:00:21Z")

</div>

Found the answer

just change

> dbt\_utils → dbt

here

---

<div class="post-metadata">

**Author:** ![joellabes](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/joellabes/32/3980_2.png) [@joellabes](https://discourse.getdbt.com/u/joellabes)\
**Post date:** [February 23, 2023, 9:38am UTC](https://discourse.getdbt.com/t/datediff-dict-object-errors-dbt-upgrades/6893/3 "2023-02-23T09:38:47Z")

</div>

Thanks for coming back and posting your solution! This is because we moved a lot of cross-database macros out of dbt utils and into dbt Core for implementation by the database adapters.

You might want to check out [Upgrading to dbt utils v1.0 | dbt Developer Hub](https://docs.getdbt.com/guides/migration/versions/upgrading-to-dbt-utils-v1.0) to check if there are any other things you should review

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/getdbt/original/1X/a7a7ca1fe379aaf90952b0e13118a817babcd14f.png) [@system](https://discourse.getdbt.com/u/system)\
**Post date:** [March 2, 2023, 9:39am UTC](https://discourse.getdbt.com/t/datediff-dict-object-errors-dbt-upgrades/6893/4 "2023-03-02T09:39:28Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
