# Downsample a year of data by weeks and month

**URL:** <https://community.influxdata.com/t/downsample-a-year-of-data-by-weeks-and-month/3998>\
**Category:** Systems\
**Created:** [February 13, 2018, 6:03pm UTC](https://community.influxdata.com/t/downsample-a-year-of-data-by-weeks-and-month/3998 "2018-02-13T18:03:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrd](https://avatars.discourse-cdn.com/v4/letter/m/ecae2f/32.png) [@mrd](https://community.influxdata.com/u/mrd)\
**Post date:** [February 13, 2018, 6:03pm UTC](https://community.influxdata.com/t/downsample-a-year-of-data-by-weeks-and-month/3998/1 "2018-02-13T18:03:27Z")

</div>

Hello,

we use InfluxDB for a research project where we import a CVS file containing time series data from 1 year starting at the 1. of February 2015 until 31. January 2016 of the next year with a interval of 1 hour.

We want to downsample the data by days, weeks, months and year. Day and year works as expected and gives as the same results as when we use Excel but weeks and month not. The computed sum is wrong for each record. Here are the queries we ran for down sampling:

```
// days
select sum(value) as value from m1 group by time(1d)
// week
select sum(value) as value from m1 group by time(1w)
// month
select sum(value) as value from m1 group by time(4w)
// year
select sum(value) as value from m1

```

Strangely the time of the first record in week and month is always previous the first time entry of the raw data.

---

<div class="post-metadata">

**Author:** ![sbains](https://avatars.discourse-cdn.com/v4/letter/s/cdc98d/32.png) [@sbains](https://community.influxdata.com/u/sbains)\
**Post date:** [February 14, 2018, 7:23am UTC](https://community.influxdata.com/t/downsample-a-year-of-data-by-weeks-and-month/3998/2 "2018-02-14T07:23:57Z")

</div>

I would suggest exploring the offset function. By default it will use the Influx computed start and end times but with offset you can move the calculation start time/end time

e.g. the below will move the query by a day  
select sum(value) as value from m1 group by time(1w,1d)

> **[Data exploration using InfluxQL | InfluxDB OSS 1.7 Documentation](https://docs.influxdata.com/influxdb/v1.4/query_language/data_exploration/#the-offset-and-soffset-clauses)**
>
> Explore time series data using InfluxData’s SQL-like query language. Understand how to use the SELECT statement to query data from measurements, tags, and fields.
