Scala date range

Google it: "Scala date range". The results are... unhelpful. The top result (a Stack Overflow link, obviously) hints at a workable solution. Here's my implementation of it:

import org.joda.time.{DateTime, Period}

def dateRange(from: DateTime, to: DateTime, step: Period): Iterator[DateTime] =

To use it, provide a "from" date, a "to" date and a joda time period:

val range = dateRange(,,

Which gives you an iterator starting 5 years ago, containing every date 6 months apart, up until now. An iterator is part of scala collections - so you can toList it or map/filter etc.