DataMapper query - last year, last month etc

I use sinatra web framework and DataMapper.

I have code:

@wdata = Data.all(:date => (( - @interval.to_i)

When I want Data from last 24 hours I use @interval = 1, last 7 days @interval = 7.

How I should get data from e.g. last month or last year? Month can have 31, 30, 28 or 29 days I would like to distinguish this. I would e.g. get data from june last year, last two months, etc.

I searched in web for some tutorial, but I found only for ActiveRecord. :(


Perhaps there is more elegant solution, but you can do such ranges manually

d =
p = d.prev_month
py = d.prev_year
last_month = Data.all(:date => (, p.month), d.month))
last_year = Data.all(:date => (

Need Your Help

Make a custom ListView with List<String> in Android

java android listview android-custom-view

I have tried this , but it doesn´t work, I want to make that each one of the list(origen, destino,dias) were each one of the columns of my custom ListView.

Image Change with Mouse Hover

html css image hyperlink hover

I have some links to my facebook and twitter, these links are images. I want these links to turn lighter when I hover over them. I was thinking I could do this by making two images and making the i...