# weather data is incorrect?

**URL:** <https://forum.kx.com/t/weather-data-is-incorrect/15342>\
**Category:** Academy Support\
**Tags:** kx-academy\
**Created:** [December 8, 2025, 12:16pm UTC](https://forum.kx.com/t/weather-data-is-incorrect/15342 "2025-12-08T12:16:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjay.b5](https://avatars.discourse-cdn.com/v4/letter/v/f4b2a3/32.png) [@vjay.b5](https://forum.kx.com/u/vjay.b5)\
**Post date:** [December 8, 2025, 12:16pm UTC](https://forum.kx.com/t/weather-data-is-incorrect/15342/1 "2025-12-08T12:16:38Z")

</div>

When min date is 2009.01.01 , how come the result below has a 2008.12.27?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/kx/original/1X/e99a4e2e155efb85f91201c21a542f75f5c48be3.png)

---

<div class="post-metadata">

**Author:** ![mmcparland](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/mmcparland/32/54_2.png) [@mmcparland](https://forum.kx.com/u/mmcparland)\
**Post date:** [December 8, 2025, 3:13pm UTC](https://forum.kx.com/t/weather-data-is-incorrect/15342/2 "2025-12-08T15:13:27Z")

</div>

Hi @vjay.b5

When q groups dates using `7 xbar date`, it divides the data into **7-day buckets** , each bucket labelled by the **start of that 7-day period**.

Because the data begins on **2009.01.01** , but the natural 7-day alignment for q falls on **2009.01.03** , q aligns the buckets to that boundary. As a result, the first two dates— **2009.01.01** and **2009.01.02** —do not fill a complete 7-day group by themselves. q still includes them, but it assigns them to the bucket whose label is **2008.12.27** , which is simply _the start date of the 7-day period that includes 2009.01.01_.

This label **does not mean data came from 2008.12.27** ; it’s only the calculated start of that 7-day interval.

I hope this clears things up and if you have any questions about this, let me know! 🙂

---

<div class="post-metadata">

**Author:** ![vjay.b5](https://avatars.discourse-cdn.com/v4/letter/v/f4b2a3/32.png) [@vjay.b5](https://forum.kx.com/u/vjay.b5)\
**Post date:** [December 9, 2025, 5:07am UTC](https://forum.kx.com/t/weather-data-is-incorrect/15342/3 "2025-12-09T05:07:27Z")

</div>

Thanks Megan, that’s very helpful. But what do you mean by “ **the natural 7-day alignment for q falls on 2009.01.03** “ ? 2009.01.03 is Saturday (not Sunday) just curious how q determine the bucket period here automatically. (Am new to q/kdb perhaps am missing something)

---

<div class="post-metadata">

**Author:** ![mmcparland](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/mmcparland/32/54_2.png) [@mmcparland](https://forum.kx.com/u/mmcparland)\
**Post date:** [December 9, 2025, 11:50am UTC](https://forum.kx.com/t/weather-data-is-incorrect/15342/4 "2025-12-09T11:50:48Z")

</div>

@vjay.b5 `a xbar b` returns the _largest multiple of `a` that is ≤ b_.

So for example, say we have `7 xbar 2009.01.01` it will convert the date to internal integers from 2000.01.01 (the epoch).

2009.01.01 = 3288 days

To find the **nearest multiple of 7** to **3288** :

3288 ÷ 7 = **469.714…**

The closest two multiples to 7 are:

1. Lower multiple:  
469 × 7 = 3283 (2008.12.27)
2. Upper multiple:  
470 × 7 = 3290 (2009.01.03)

`7 xbar date` groups dates into 7-day buckets aligned to multiples of 7 days since **2000.01.01** , producing week-based buckets like:

2008.12.27  
2009.01.03  
2009.01.10

I hope this helps!
