# Transform date range into series of dates

**URL:** <https://forum.openrefine.org/t/transform-date-range-into-series-of-dates/218>\
**Category:** Support and Helpdesk\
**Created:** [December 1, 2022, 8:13pm UTC](https://forum.openrefine.org/t/transform-date-range-into-series-of-dates/218 "2022-12-01T20:13:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jessicabreiman](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@jessicabreiman](https://forum.openrefine.org/u/jessicabreiman)\
**Post date:** [December 1, 2022, 8:13pm UTC](https://forum.openrefine.org/t/transform-date-range-into-series-of-dates/218/1 "2022-12-01T20:13:54Z")

</div>

Hi Everyone,

I am working with some museum metadata that we are integrating into a library catalog. The date format for museum objects is often formatted as a range of years (eg. 1901-1924). However, for our discovery system to be able to read a range of years correctly it has to be formatted as a series like so: 1901;1902;1903;1904;…1924).

I’m not sure how to approach this type of transformation without integrating a lot of individual record work on top of some GRELs. Anyone have a suggestion as to how I could accomplish this?

Many thanks!

Jessica

---

<div class="post-metadata">

**Author:** ![b2m](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.openrefine.org/b2m/32/139_2.png) [@b2m](https://forum.openrefine.org/u/b2m)\
**Post date:** [December 1, 2022, 9:43pm UTC](https://forum.openrefine.org/t/transform-date-range-into-series-of-dates/218/2 "2022-12-01T21:43:21Z")

</div>

So this is a naive algorithm in GREL:

1. We [split](https://openrefine.org/docs/manual/grelfunctions#splits-s-or-p-sep-b-preservetokens-optional) the range “1901-1924” on the dash.
2. We use a [variable](https://openrefine.org/docs/manual/grel#withe1-variable-v-e2) called `years` to save the splitted range.
3. We use [forRange](https://openrefine.org/docs/manual/grel#forrangen-from-n-to-n-step-v-e) to enumerate all the years in the splitted range.
4. We [join](https://openrefine.org/docs/manual/grelfunctions#joina-sep) the resulting array into a string using "; " as separator.

```javascript
with(
  value.split("-"),
  years,
  forRange(
    years[0].toNumber(),
    years[1].toNumber()+1,
    1,
    year,
    year))
.join("; ")

```
