# Datetime RangeBetween in Pipeline Builder

**URL:** <https://community.palantir.com/t/datetime-rangebetween-in-pipeline-builder/2494>\
**Category:** Ask the Community\
**Tags:** pipeline-builder\
**Created:** [January 10, 2025, 2:18pm UTC](https://community.palantir.com/t/datetime-rangebetween-in-pipeline-builder/2494 "2025-01-10T14:18:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkiffel](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mkiffel](https://community.palantir.com/u/mkiffel)\
**Post date:** [January 10, 2025, 2:18pm UTC](https://community.palantir.com/t/datetime-rangebetween-in-pipeline-builder/2494/1 "2025-01-10T14:18:08Z")

</div>

Is this query possible in PB?

> “”"  
> SELECT \*, sum(qty\_lost\_sales) OVER (  
> PARTITION BY sku\_number  
> ORDER BY CAST(lookup\_date AS timestamp)  
> RANGE BETWEEN INTERVAL 365 DAYS PRECEDING AND CURRENT ROW  
> ) AS qty\_lost\_sales\_L12M FROM dat\_lookup\_lost\_sales\_input  
> “”"

qty\_lost\_sales `double`  
lookup\_date `date`  
sku\_number `str`

PB\>Window\>RangeBetween does not seem to allow to order by timestamp types.

Should I try and cast “lookup\_date” as Double/Int with epoch time conversion?

---

<div class="post-metadata">

**Author:** ![helenq](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@helenq](https://community.palantir.com/u/helenq)\
**Post date:** [January 10, 2025, 3:33pm UTC](https://community.palantir.com/t/datetime-rangebetween-in-pipeline-builder/2494/2 "2025-01-10T15:33:52Z")

</div>

Hey! Yeah I would try out casting the lookup\_date as a double/int and then ordering. Let us know if you’re still running into issues though

---

<div class="post-metadata">

**Author:** ![mkiffel](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mkiffel](https://community.palantir.com/u/mkiffel)\
**Post date:** [January 13, 2025, 5:33pm UTC](https://community.palantir.com/t/datetime-rangebetween-in-pipeline-builder/2494/3 "2025-01-13T17:33:17Z")

</div>

> [@helenq](#):
>
> casting the lookup\_date as a double/int and then ordering

That worked, thanks.

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/palantir/user_avatar/community.palantir.com/system/32/3_2.png) [@system](https://community.palantir.com/u/system)\
**Post date:** [January 27, 2025, 5:33pm UTC](https://community.palantir.com/t/datetime-rangebetween-in-pipeline-builder/2494/4 "2025-01-27T17:33:32Z")

</div>

Closed on January 27, 2025, 5:33pm UTC

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