0

So basically, I want to create reports for my Attendance Records Table.

Table has :user_id, :clock_in, :clock_out, :seconds columns that are being updated.

Basically my report needs: to calculate (sum of :seconds) for a given period.

I.e. Jan 1, 2014 to Jan 31, 2014 ... I would like to list all records from this daterange, and in the end would calculate sum of :seconds.

Any ideas how would I approach this?

meritonch
  • 43
  • 9
  • You need to make an attempt to solve the problem yourself. Then, come back to us here and show us what you have attempted. On that we can comment and/or provide answers. –  Jan 11 '15 at 19:17
  • Yes, how would **you** approach this @meritonch? – hd1 Jan 11 '15 at 19:19
  • To be honest, I have no idea. have never worked with reports or what would I need. Thats why i wanted to get at least some idea of what would I need to achieve this. – meritonch Jan 11 '15 at 19:19
  • You can ask to calculate sum of :seconds at db engine – rfellons Jan 11 '15 at 19:22
  • @meritonch Can you review my answer? – rderoldan1 Jan 15 '15 at 13:48

1 Answers1

0

Your question is very general, please, before question try to do some work and come with technical questions.

Tips

  1. Your question is related about SQL, basically you need to perform a select query

    select * from your_table where date <= your_date and date >= your_date
    

    Need help on mysql date range query

  2. In rails, where clauses are build by ActiveRecord

    YourModel.where('date <= ? and date >= ?', your_date. your_date)
    

    Rails where date is greater than given date query

  3. If you need something more advanced, use Ransack

    http://railscasts.com/episodes/370-ransack
    

    Hope I can help you ;)

Community
  • 1
  • 1
rderoldan1
  • 3,517
  • 26
  • 33