Subtract days from date

Hi,

I want to be able run a query on table which will do a count for all rows from the beginning of the week. I am using the getDayofWeek block to get the number of the day and want to use that to calculate how many days I have to go back to get to the beginning.

e.g. Thusday is 4, so I know that I have to go back 3 days to get Monday. Question is, what block or blocks can I use to subtract x days from the current date?

Would I have to use the Offset seconds block?

Thanks
Steve

Hi Steve,

This can be done by using a database function in a where clause. All available database functions are documented here:

https://backendless.com/docs/rest/data_database_functions.html#datetime-functions

To deduct 3 days from today and run a query for all objects created since then, you would use the following where clause:

created > DATESUB(NOW(), 3, 'DAY')

Regards,
Mark

Thanks Mark for the speedy response!

The Backendless Team surely know how to keep it’s community happy!!!

1 Like