Search code examples
sap-commerce-cloud

How to get all products that have been created within H number of hours using flexible query in hybris?


Can anyone please suggest a flexible query to get all products which have been added within H number of hours in hybris?


Solution

  • You can use SQL functions.

    This should work for SQL Server:

    SELECT * FROM {Product} WHERE {creationtime} > DATEADD(mi,-60,GETDATE())
    

    The DATEADD portion means means subtract 60 minutes from the current date.

    For other databases, you may need to look for a similar or equivalent function.