Hi,
I wanted some assistance on how to write a where clause for a db query where results returned are within a certain time frame.
For example: Return only user entries that were last updated 24 hours ago.
I looked at the DATEDIFF function but I don’t know how to structure this.
Innocent.
Hi @Innocent_Nwaukwa
You can use functions or a combination of functions from this documentation: Database Functions - Backendless REST API Documentation.
For example, in your query, you can write a condition like this:
DATEDIFF(NOW(), updated) >= 1
Here, DATEDIFF will return the difference in days between two dates and will accordingly return records that were updated yesterday and earlier.
You can also use the function:
DATESUB(NOW(), 24, 'HOUR') > updated
Here, DATESUB will subtract 24 hours from the current time and compare it with the date from the ‘updated’ column.
Regards,
Viktor
Thanks!
That explains it perfectly.
Innocent.