# Querying Using Timestamp Components

**URL:** <https://forum.kx.com/t/querying-using-timestamp-components/8003>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [November 21, 2012, 9:29am UTC](https://forum.kx.com/t/querying-using-timestamp-components/8003 "2012-11-21T09:29:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rory\_Winston](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Rory\_Winston](https://forum.kx.com/u/Rory_Winston)\
**Post date:** [November 21, 2012, 9:29am UTC](https://forum.kx.com/t/querying-using-timestamp-components/8003/1 "2012-11-21T09:29:00Z")

</div>

Hi guys

If I have a table where the ‘x’ column (say) is of type timestamp, how can I use it to restrict / subset queries?

Say if I want all results after 18:00;

select from x where `hh$timestamp \> 18

Or a ranged query:

select from xwhere `hh$timestamp within (12;14)

Neither of the above work for me - not sure what Im missing…

Thanks!

– Rory

---

<div class="post-metadata">

**Author:** ![charlie1](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@charlie1](https://forum.kx.com/u/charlie1)\
**Post date:** [November 21, 2012, 10:03am UTC](https://forum.kx.com/t/querying-using-timestamp-components/8003/2 "2012-11-21T10:03:00Z")

</div>

.. where (`hh$p) within ..

if you still have the problem, please mention you version/release.

thanks

---

<div class="post-metadata">

**Author:** ![Rory\_Winston](https://avatars.discourse-cdn.com/v4/letter/r/e99b99/32.png) [@Rory\_Winston](https://forum.kx.com/u/Rory_Winston)\
**Post date:** [November 21, 2012, 10:18am UTC](https://forum.kx.com/t/querying-using-timestamp-components/8003/3 "2012-11-21T10:18:00Z")

</div>

Thanks Charlie - that did it.

Just curious (to aid my own understanding) &nbsp;- what is the reason? I take it its some sort of precedence / binding rule?

Cheers

– Rory
