# Preserve query results at a point in time

**URL:** <https://discourse.getdbt.com/t/preserve-query-results-at-a-point-in-time/5926>\
**Category:** Help\
**Tags:** snapshots\
**Created:** [January 6, 2023, 3:12pm UTC](https://discourse.getdbt.com/t/preserve-query-results-at-a-point-in-time/5926 "2023-01-06T15:12:29Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [January 11, 2023, 5:58am UTC](https://discourse.getdbt.com/t/preserve-query-results-at-a-point-in-time/5926/6 "2023-01-11T05:58:42Z")

</div>

> [@bonnevie](#):
>
> Could you give an example of doing a “time travel”/fixed-point-in-time query with a snapshot?

Do you mean how do you query a snapshot table to get a point-in-time result? If so then,

> [@bonnevie](#):
>
> Is it as simple as only selecting rows in the correct valid range?

yes!

You would do something like

```sql
select * 
from {{ ref('the_snapshot') }} 
where getdate() between dbt_valid_from and dbt_valid_to

```

, keeping in mind that the current version of a row will have `dbt_valid_to` of null. It’s common to coalesce that to a value in the distant future for ease of querying, normally something like `2099-12-31`.

Check out [Building models on top of snapshots](https://discourse.getdbt.com/t/building-models-on-top-of-snapshots/517) for our best practices when working with snapshots.

> [@bonnevie](#):
>
> And are you at risk of a full refresh with snapshots, or are they always continuously updated?

Snapshots are updated each time you run the `dbt snapshot` command, and will never be dropped by dbt, even with a `full-refresh` command. It’s a good idea to put your snapshots into a different schema to prevent someone from accidentally dropping them, as their data is by definition non-recoverable (without backups), in contrast to most dbt models where as long as you have the source tables you can get back to the starting point.

---

_[View the full topic](https://discourse.getdbt.com/t/preserve-query-results-at-a-point-in-time/5926)._
