I have spent hours trying to make this next piece of code work.
import org.joda.time.{DateTime, Period}
def dateR
Ok, Here is the complete working code.
import org.joda.time.{Period, DateTime}
object runme {
def main(args:Array[String]) {
def dateRange(from: DateTime, to: DateTime, step: Period): Iterator[DateTime]
=Iterator.iterate(from)(_.plus(step)).takeWhile(!_.isAfter(to))
val range = { dateRange(new DateTime(2000, 06, 30,0,0,0,0).minusYears(5) ,new DateTime(2013, 06, 30,0,0,0,0),new Period(0,6,0,0,0,0,0,0))}
range.foreach(u => {
print(u.getYear)
print(u.getMonthOfYear)
println(u.getDayOfMonth)
})
}
}
I think my main problem was not having enough numbers after the DateTime() functions (ie the milliseconds etc.) this meant the compiler wasn't receiving all the parameters that it wanted. As mentioned by Alexey Romanov
This then prints the dates for a desired range, and can be used as an iterator.
Hope that helps others.
Thanks @Brian and others for the Help