Postgres ::date not working on Custom Query

Wappler Version : 5.1.9
Operating System : Mac OS
Server Model: NodeJS
Database Type: Postgres
Hosting Type: Docker

Expected behavior

What do you think should happen?

Using the ::date, as created_at::date should return only the date of the timestamp field.

Actual behavior

What actually happens?

It’s not applying the function, returning the full timestamp field.

How to reproduce

Create a custom query, select one timestamp field an then apply the ::date function.
E.g: select created_at::date from table

::date is working fine on pgAdmin, but not on Wappler.

PG Admin return

Captura de Tela 2022-10-13 às 19.17.09

Wappler return

Captura de Tela 2022-10-13 às 19.17.50

I tried to change the type on custom query schema to date and to date and time, but without success.

Any clue?
Thanks!

Try this instead of casting to date: TO_CHAR(created_at, 'YYYY-MM-DD')

Knex handles dates weirdly. Refer this: Timestamp Column Converted to UTC In Wappler

1 Like

The postgreSQL driver in node converts all date/time related values to a JavaScript Date object. The JavaScript Date object will always contain date and time information.

use: created_at::date::text

1 Like

thanks guys!!

created_at::date::text worked!
Cast didn’t work, @sid, but thank you for your time, anyways :smiley: