Split datetime into 3

Hi,

I am trying to sort a a chart of my database entries. I would like to
sort by weekday, date, & time. I want to be able to do each
separately. I would like to be able to process this through the find
‘sql’ the order by. This might sound a little confusing but the goal
is to be able to sort the data by the weekday, date, or time. Please
let me know if you can help or you have any questions.

Thanks,
Nathan

This my way in this case:

@bill_pays = BillPay.find(:all)

@sorted_by_time = @bill_pays.sort_by{|x| x.paid_at.strftime(’%H:%M:%S’)}

@sorted_by_date = @bill_pays.sort_by{|x|
x.paid_at.strftime(’%d/%m/%Y%’)}

for bill in @bill_pays

if bill.paid_at.strtime(’%W’).to_i > 5
@bill_pays = @bill_pays - bill.to_a
end

end

@sorted_by_weekday = @bill_pays.sort_by{|x| x.paid_at}

Sorry I can not answer in find_by_sql, maybe other people here will
answer.

Good Luck,

Reinhart
http://teapoci.blogspot.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs