0

I am building an app using node with a Postgres backend. I have a column for date where the data type is date. The dates in the database are stored in the format YYYY-MM-DD. However, when I do a query in my app, the date returned is in the format YYYY-MM-DD + (time zone information). For example:

2016-01-06T05:00:00.000Z

Does anyone know how I can prevent this?

Thanks in advance!

1 Answer 1

1

Use to_char

SELECT to_char(dateColumn, 'YYYY-MM-DD') AS formattedDate FROM ...

Example:

ubuntu=> SELECT to_char(to_timestamp('2016-01-07', 'YYYY-MM-DD'), 'YYYY-MM-DD');
  to_char
------------
 2016-01-07
(1 row)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.