1

I have a column with deadlineDays (integer), i need a filter with column in a grails gorm :

def products = Product.withCriteria() {
            createAlias("company", "comp")
            eq("comp.autoProductApproval", true)
            le("statusDate", new Date())
            notExists(subQuery)
            maxResults(100)
        }

In le("statusDate"... i need subtract (new Date() - comp.deadlineDays())

How do this in grails gorm?

Mister B
  • 123
  • 2
  • 15
  • Possibly use `HQL` refer to https://stackoverflow.com/questions/15403544/number-of-days-between-two-given-dates/15403576#15403576 `SELECT DATEDIFF(day, isnull(@startdate,GetDate()), isnull(@enddate,GetDate()))` where you pass in the two dates and this provides numerical value out of sql – V H Jun 14 '18 at 14:40
  • fixed problem, used : sqlRestriction("status_date < DATE_SUB(now(), INTERVAL deadline_days DAY)") – Mister B Jun 20 '18 at 14:22

0 Answers0