How to calculate difference between two dates that should support both ORACLE and MYSQL database?

85 Views Asked by At

My application supports both databases oracle and MySQL, now I need to calculate difference between two dates .

My code is working with Oracle as it supports " - " operator, but it will not work with MySQL. MySQL has a DATEDIFF function to calculate difference.

  Query query1 = entityManager.createQuery("select ast.id,ast.name from ActSubT ast where ast.unSubDt - ast.subDt <= 1 ");
 List<Object> result=query1.getResultList();

Do we have any option by which I can calculate difference with same query and should work with both MySQL and Oracle? I don't want to write two different queries

0

There are 0 best solutions below