Search code examples
mysqlruby-datamapper

Order BY diffrence of two columns using DataMapper


I have a mysql table.
It contains 2 Column (startdate,enddate)
Both are of DateTime type Using sql

select * from ABC order by (enddate-startdate) DESC;

same thing i want in datamapper...but i m not able to do it Plz help


Solution

  • Thanks, i got one datamapper function to run sql query directly

    repository(:default).adapter.select('select * from ABC order by (enddate-startdate) DESC')