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