How to find records by month Datamapper

前端 未结 1 1252
面向向阳花
面向向阳花 2020-12-22 09:59

In my project I need to have ability ti add reports. Adding a report user can choose date for placing his report. (not created_at) I save this data in \"Date\":DataTime - fo

相关标签:
1条回答
  • 2020-12-22 10:41

    No. You should calculate margin dates and use :date => range (it will create sql BETWEEN query). For example:

    month = params[:month].to_i
    date_a = DateTime.new Date.today.year, month, 1
    date_b = (date_a >> 1) + 1  # will add a month and a day
    Page.all :updated_at => date_a..date_b
    
    0 讨论(0)
提交回复
热议问题