Search code examples
sqldatedqldocumentum

Datediff function of DQL is not returning results as expected


I am trying to query documentum server using DQL query. Using DATEDIFF function to select data that are created in the current date. Here is the query

    SELECT title FROM content_table WHERE DATEDIFF(day, "r_creation_date", DATE(TODAY)) < '1' AND content_type IN ('story','news')

Problem is along with today's data its selecting yesterday's also. Why is less than 1 condition fetching yesterday's data also?

Have tried using DATEDIFF(day, "r_creation_date", DATE(TODAY)) = '0' but that does not fetch any result. I understand even the time comes into picture but as I am using 'day' as the date pattern will it not just calculate difference of the days alone?


Solution

  • You can try this query:

    SELECT title FROM content_table WHERE r_creation_date > DATE(TODAY) AND content_type IN ('story','news')
    

    if you need the objects created today (after 00:00, not in the last 24 h)