Database Query equal to TODAY

Hey Guys,

I’ve hit a bit of a wall with this query - I’m wanting to display bookings stored in db for today (and other days but i’ve found some write-ups about this).

Its just showing me nothing when i try to put it in a table - the data (date and time) is stored in this format: 2020-12-07 15:51:00 (year month day)

I’ve tried {{NOW}} but I’m wondering whether the time stored in the database is throwing it off?

Any suggestions would be greatly appreciated

Thanks in advance!

Ben

Try:

where bookingDate >= CURRENT_DATE

Should work for you.

More information:

Hi Dave,

Thanks for your reply but that’s not working either. I believe its an issue with how it’s formatted in the database - as “current date” is not going to match eg. 2020-12-07 15:51:00

@Teodor sorry i might need to bother you again, I know it’s been a while!

the row type is datetime and saves in this format: 2020-12-07 15:51:00

If I use equal to {{NOW}} obviously now is pretty much always going to be after any records added that day.

Is the only way to do this just to create a custom query?

Thanks,
Ben

Ok seem to have got it working with a custom query using CAST

In Example:

SELECT * FROM jobs WHERE CAST(datetimebooked AS DATE) = CURRENT_DATE

Thanks @Dave for the CURRENT_DATE snippet :smile:

2 Likes

In the past I’ve also used formatters to get around this issue, for example

bookingDate == NOW.formatDate('yyyy-MM-dd')

That then shortens 2020-12-07 15:51:00 down to 2020-12-07 which can be read by server/app connect no matter what second/minute/hour of the day the action is run.

1 Like