Date handling with MySQL--wrong date displayed

I'm trying to update/handle dates in MySQL and having several issues. The first is that the system displays the date one day before what is in the database. In other words when I use a list query through the preview it shows one date and when I run the app it shows a different date (one day earlier). This seems anomalous.

->What's displayed in the table through a list query: Aug 4, 2021 8:00 PM

->What's in the database: 2021-08-05T00:00:00.000Z

Here is the query that I am using to generate the update to the field:

update clauses set ModifiedWhen = {{moment().format('YYYY-MM-DD')}} where ClauseKey = {{Clauses.selectedRow.data.ClauseKey}}

Writing this on 8/5 by the way.

Any thoughts on why this is happening and how to rectify. Thanks

1 Like

@mcolacino I always encounter this. I think you better use moment like this:
{{ moment.utc(self).format('DD MMM YYYY HH:mm:ss') }} where self is the column in my table. I'm not sure how moment is taking the locale considerations when NOT using .utc. But this solution worked for me.

EDIT:
Note: you can remove self here and use moment as is with utc.

{{ moment.utc().format('YYYY-MM-DD') }}